Click here to Skip to main content
15,884,978 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a list of string (with prefix '@') which are the same as my procedures parameter's list.

So when I am trying to access a string from this list, its give me the name of that parameter and not parameter value.

My SP is here
----
CREATE PROCEDURE MYSP(@Fname varchar(max),@Lname varchar(max))
AS
BEGIN
DECLARE @ParamList AS CURSOR
DECLARE @ParamName AS varchar(100)
SET @ParamList = CURSOR FOR SELECT pParameter FROM dbo.GetParameterList('Function')
//Function returns list of string which are parameter list @Fname,@Lname

OPEN @ParamList
FETCH NEXT FROM @ParamList INTO @ParamName
WHILE @@FETCH_STATUS = 0
BEGIN
Print @ParamName // I would like to print the value of parameter @Fname and not '@Fname'
FETCH NEXT FROM @ParamList INTO @ParamName
END

CLOSE @ParamList
DEALLOCATE @paramList
END

So how could I do this?
Thank you.
Posted
Updated 9-Jun-14 1:06am
v3
Comments
OriginalGriff 9-Jun-14 6:56am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
What you have told us doesn't make a lot of sense: perhaps if you show the relevant parts of your SP, and an example of how you call it?
Use the "Improve question" widget to edit your question and provide better information.

1 solution

SQL does not support accessing parameters via names stored in other variables.
What you may do is dynamic SQL using sp_executesql[^]...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900