Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how to access parameters via names stored in other variables

$
0
0
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.

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>