Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in SQL Server only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
SQL Server
Return more than one value(store procedure)
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
MATTXtwo
New Member
Join Date:
Sep 2006
Posts:
83
#1
Return more than one value(store procedure)
Nov 7 '08, 01:44 AM
can i do like this Return (4),@fieldname
an how to asign value @fieldname with the value of fieldname that use select from table?
Delerna
Recognized Expert
Top Contributor
Join Date:
Jan 2008
Posts:
1134
#2
Nov 12 '08, 10:16 PM
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
[code=sql]
set @fieldname=(sel ect TheField from TheTable)
[/code]
Of course, the select statement must return 1 record only in the above example.
Comment
Post
Cancel
Delerna
Recognized Expert
Top Contributor
Join Date:
Jan 2008
Posts:
1134
#3
Nov 12 '08, 10:30 PM
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
[code=sql]
DECLARE @SQLString NVARCHAR(500) --Must be NVARCHAR
set @SQLString='SEL ECT ' + @fieldname + ' FROM YourTable'
EXEC sp_executesql @SQLString
[/code]
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment