Easy SQL question. How to display query results in Query Analyzer


When I run the following query from Query Analyzer in SQL Serer 2005, I get a message back that says.

Command(s) completed successfully.


What I really need it to do is to display the results of the query. Does anyone know how to do this?


declare     @SniierId as   uniqueidentifier
set @SniierId = '85555560-AD5D-430C-9B97-FB0AC3C7DA1F'
declare    @SniierAlias  as nvarchar(50)
declare    @AlwaysShowEditButton  as bit
declare     @SniierName  as  nvarchar (128)
/* Check access for Sniier */
SELECT TOP 1
       @SniierName      = Sniiers.SniierName,
        @SniierAlias    = Sniiers.SniierAlias,
        @AlwaysShowEditButton = Sniiers.AlwaysShowEditButton
FROM Sniiers
WHERE Sniiers.SniierId=@SniierId

0
brgdotnet
2/12/2008 11:21:08 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
872 Views

Similar Articles

[PageSpeed] 40
Get it on Google Play
Get it on Apple App Store

The reason you aren't getting any results is because your select statement is assigning values to parameters. I am not sure why you are doing this, but you could either use a regular select statement, or use PRINT to print out your parameters, like this:

 

declare     @SniierId as   uniqueidentifier
set @SniierId = '85555560-AD5D-430C-9B97-FB0AC3C7DA1F'
declare    @SniierAlias  as nvarchar(50)
declare    @AlwaysShowEditButton  as bit
declare     @SniierName  as  nvarchar (128)
/* Check access for Sniier */
SELECT TOP 1
       @SniierName      = Sniiers.SniierName,
        @SniierAlias    = Sniiers.SniierAlias,
        @AlwaysShowEditButton = Sniiers.AlwaysShowEditButton
FROM Sniiers
WHERE Sniiers.SniierId=@SniierId

PRINT @SniierName
PRINT @SniierAlias
PRINT @AlwaysShowEditButton
 
Cheers,
       Kevin Jones


0
vcsjones
2/13/2008 12:39:51 AM

If you want a resultset, you should be doing this:

SELECT TOP 1
      Sniiers.SniierName,
       Sniiers.SniierAlias,
       Sniiers.AlwaysShowEditButton
FROM Sniiers
WHERE Sniiers.SniierId=@SniierId


[C# MVP]
Unblog|WebSite|IttyUrl
0
pbromberg
2/13/2008 1:37:58 AM

just use the print command as

print @SniierName

 

 

mark as answer if it helps you

0
roopsi_saxena
2/14/2008 1:45:33 PM
Reply:

Similar Artilces:

Combine SQL query result with XML query result
Hi all, Hopefully someone can help me with this: I know how to setup and run a query on an SQL db and I can probably work out how to query an XML file, but how do I take the results of each and combine them into one collection (i'm presuming a dataset)? Once i've created the combined collection, i'd want to order it by some universal identifier present in both datasources e.g. product ID. It's worth pointing out that the XML file would not be in the same format/use the same field names (or number of fields) as the SQL query, so I guess I might need to bind my query resu...

Can sql queries be nested in sql queries?
I am having problems with a template that uses the information from one sql query to generate a query on another table. Let me be more specific. The template in question receives a category ID value from a web page that provides a menu of several categories to choose from. Each Category ID represents several Items or products to choose from. When the template receives the category ID, the first thing it does is run a query on my item_category table (this table lists all of the items and associates them with the appropriate category). This query returns several itemIDs that are all...

sql or my sql query
hi,in my database  i have the two tables...1)programs                                2)reservedin the programs...two fields 1)program id           2)maxseats................these details wil be entered by adminin the reserved table  two fileds ..1)PRogramid        2)statusmy requirement is .. i need the available seats..meansif any body is intersted in  any program...they wil select the program...then status becomes approved(1)..then i need the o/p as ...

Query Result in SQL Analyzer
I have query like this. select case BOND when 'IP-1' then volume end as [IP-1], case BOND when 'IP-9' then volume end as [IP-9], case BOND when 'IP-12' then volume end as [IP-12], case BOND when 'IP-41' then volume end as [IP-41], case BOND when 'SBU' then volume end as SBU, case BOND when 'SBL' then volume end as SBL, case BOND when 'SBT' then volume end as SBT, case BOND when 'SBR' then volume end as SBR from (select fromnode,tonode,volume,substring(fromnode,3,2) IP, fromnode % 10 fromnode2, tonode % 10 tonode2, case when substring(fromnode,3,2)=...

C# Ado.net Sql query parameter query
Hi All, I'm trying to pass in a parameter value from an array in a loop that is used in a sql query and the results are populated to an xml file. The trouble is that I'm only getting the colums values in the outputted xml file. So I feel that the paramter is not being read. So can anyone help as I'm really stuck on this one. The code is as follows : public void DisplayUserInfo() { ArrayList UserIdArrayList = IdentifyUserID(); foreach(string ShowUserIDString in UserIdArrayList) { try { SqlConnection SqlConn = new SqlConnection(DBConnString)...

can i do an sql query then use the result of that in another query...
for instance i need to find value of storyId from one table then make sure i do not pull that record from another table. is this possible With SQL you can do something like this: select * from TableB where StoryIdValue not in (select StoryIdValue from TableA) This is just 1 of many possible solutions. ChrisDont forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. Yes this is possible. This is what is called a "Nested Query" in SQL. ...

Display Result of SQL Query In a Table
Hello all, here is my problem. I have made an asp page that executes a SQL query on an MS Access database. This all works fine. I can even display the values returned using Response.Write. But what I want is for the result of my SQL query to be displayed in Table form, with Columns and Column Headings. Any assistance would be much appreciated.  You have 3 controls in the .net 2.0 to display data. Without code work. Just follow the wizards. Those controls are: datagrid, detailsview e formview. You can find in the net tutorial of how to use each of them   u can define a s...

Question about SQL Server/Query Analyzer and timeouts
I was given a list of user comments from an old application and told to match it up with our current system.  After all the easy methods I was still left with 95% of the records unmatched.  The only way I had left was to try and match up the names.  Given that people could have the same name I added a count to make sure it only found one record.  This query has been running for over an hour now.  How do I tell if it's actually running, or if it locked up? Also here is the query I'm using, does anyone have any feedback on it?  Is this poorly written, is my logic...

SQL query question concerning distict results
hi,I have a query in which I am getting identical results, but I can't use the distict keyword because distinct requires you select the column that you are sorting by. If I do this my results are no longer distinct. Does anyone know how to resolve this issue? keepin' it real in the ATX. Can you post the query and also some sample data containing identical rows so we can help you in a better way? ***********************Dinakar NethiLife is short. Enjoy it.*********************** ok, but it's not very easy to read.Basically if I remove xnr.relatebegin from the select my re...

IF EXISTS SQL Question
I want to only go after Distinct email addressess that contain an @ symbol. But then I want to return all fields. How do you correctly do that for Microsoft SQL Server?IF EXISTS (SELECT DISTINCT user_username FROM usr WHERE(user_username LIKE N'%@%')) SELECT * FROM usr Order By user_username   Try something like:  IF EXISTS (SELECT DISTINCT user_username FROM usr WHERE(user_username LIKE N'%@%'))BEGINSELECT * FROM usr Order By user_usernameEND  IF EXISTS only checks for existence of a record matching the WHERE condition. The SELECT is never ...

Display Result of SQL Query In a Table #2
Hello all, here is my problem. I have made an asp page that executes a SQL query on an MS Access database. This all works fine. I can even display the values returned using Response.Write. But what I want is for the result of my SQL query to be displayed in Table form, with Columns and Column Headings. Any assistance would be much appreciated. Can you post what you have code-wise so we can build upon that? If this post helped you, Mark As Answer. Hello HawkBat, On MSDN and ASP.NET a lot of samples and tutorials are available, for example: http://msdn2.microsoft.com/e...

VB .NET Dataset SQL query results
Hi, I'm hoping someone can shed some light on how I can address variables returned to a dataset via a stored procedure.I've coded an AJAX Autocomplete control but due to the restriction of the control (only being able to return one value) I now need to use the returned value to search my DB.  The stored procedure used for the Autocomplete returns the key information (and the description).  I'm assuming the key info is stored within the dataset. So my question is, how do I read the key information into a variable for use elsewhere?Stored proc Select Statement; SELECT SU...

Display an image based on a SQL query result.
Hello - I Like to Display an image based on a SQL query result. For example if my sql query returns a ‘5’  - I like to display OK.gif If my sql query returns a ‘1’ - I like to display down.gif Any help with the code would be much appreciated !   Thank You !   Hi Studio F1, first of all you should build a function that translate the sql query result into image url, something like: public string BuildPath ( string code ) { if ( code == "5" ) { return "images/Ok.gif" ; } else if ( code == "1" ) { return "images/down.gif" ; } else { return "images/unknown.g...

SQL Query , SQL or Procedural
HIHi i need some help on what the SQL query would be, let's say i have a resultant table like this. Group TestID Result A AA 10 A BB 30 A CC 20 B AB 200 B AC 300 A DD 50 C AA 1000 and i need to query by group and re-name every field as its TestID value for that selected group:  Example:if group "A" is selected: AA BB CC DD 10 30 20 50 if group "B" is selected: AB BC 200 300 and so on.. thanks.   Here is a sample for you to play with PIVOT: SELECT [...

Web resources about - Easy SQL question. How to display query results in Query Analyzer - asp.net.sql-datasource

West Lothian question - Wikipedia, the free encyclopedia
He illustrated his point by pointing out the absurdity of a Member of Parliament for West Lothian being able to vote on matters affecting the ...

Andrew Robb trade trip with former Nash staffer Alastair Furnival raises questions
Labor Senator Penny Wong says inclusion of former junk food lobbyist in trade delegation raises "serious questions about integrity of the ...

Angry Liberal MPs question Tony Abbott 'resistance movement' and Monkey Pod lunches
Liberal MPs are increasingly frustrated a "resistance movement" has sprung up around former prime minister Tony Abbott.

Facebook’s Helen Crossley on the 3 Big Mobile-Commerce Questions
Mobile grabbed hold of the holiday shopping season in 2014, and there is no reason to believe that trend won’t continue this year. Helen Crossley ...

Submit Your Questions For Autoblog Podcast #456
Filed under: Podcasts On Episode #456 of the Autoblog Podcast, we'll discuss our drive of the Mazda CX-9, Volkswagen's TDI fix, and this week's ...

‘The Walking Dead’ episode 7: A heart-pounding answer to ‘the Glenn question’
The seventh episode of The Walking Dead season 6 aired last night, and it had an interesting overall theme: people need saving. Unexpectedly, ...

Housing Rebound Didn't Lift Economy as Much as Economists Expected: Why?; Six Questions for Zandi
Home prices are nearly back to where they were before the crash. In some places, home prices are above where they were at the peak of the national ...

Real question: did Brad Pitt wear a ’90s wiglet at ‘The Big Short’ premiere?
Brad Pitt could potentially have a film at the Oscars this year. NO, not By the Sea . His real Oscar-bait film this year is The Big Short , which ...

Want a job at Apple? Here are 10 of the toughest interview questions
We alternately praise and criticize the folks at Apple depending on whether they just created the iPhone or Apple Maps, but there’s no doubting ...

Trump questions Hillary's 'stamina,' apparently unaware of her marathon Benghazi hearing
Donald Trump will find a new criticism of Hillary Clinton soon because his latest one is downright ludicrous. In an appearance on ABC’s “This ...

Resources last updated: 11/25/2015 8:11:09 PM