468,316 Members | 1,989 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,316 developers. It's quick & easy.

Return more than one value(store procedure)

can i do like this Return (4),@fieldname
an how to asign value @fieldname with the value of fieldname that use select from table?
Nov 7 '08 #1
2 3260
Delerna
1,134 Expert 1GB
I don't follow what you mean by

Return (4),@fieldname
Please explain more fully?

as to assigning @fieldname to the result of a select

Expand|Select|Wrap|Line Numbers
  1.  
  2. set @fieldname=(select TheField from TheTable)
  3.  
  4.  
Of course, the select statement must return 1 record only in the above example.
Nov 12 '08 #2
Delerna
1,134 Expert 1GB
If you mean you want to return the value of a field that is identified by @fieldname, then you will need to use dynamic query for that.

something like

Expand|Select|Wrap|Line Numbers
  1.  
  2. DECLARE @SQLString NVARCHAR(500) --Must be NVARCHAR
  3.  
  4. set @SQLString='SELECT ' + @fieldname + '  FROM YourTable'
  5.  
  6. EXEC sp_executesql @SQLString
  7.  
  8.  
Nov 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by Cognizance | last post: by
1 post views Thread by tfs | last post: by
7 posts views Thread by kandi111777 | last post: by
2 posts views Thread by philip | last post: by
reply views Thread by c81 | last post: by
2 posts views Thread by semi_evil | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.