Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to store parameter values and parameter names?

Status
Not open for further replies.

bluecjh

Programmer
Mar 12, 2003
385
Code:
declare @test varchar(1000);
set @Test = '';
SELECT    
	@Test = @Test + ',' + c.name
FROM      
	syscolumns c
	INNER JOIN sysobjects O On c.id = o.id
WHERE     
	o.id = @@procid

select @Test
with the above i can get and store @parameter names
from a procedure, is there a way to combine
the parameter values which i want to store and
associated witht the parameter names, i'm stumped

BlueCJH
 
I don't think you can store parameter values in this fashion, the whole purpose of using parameters is that you can supply the values at run time.

Are you trying to log this information each time your SP executes? If so, you probably could just add a query like this (provided your log table exists)

Code:
insert into LogTable
select 'ProcName', '@ParamName', @ParamName

This will insert the ProcName and parameter name (hard coded by you), followed by the parameter value (which can vary). Is this what you are looking to do?

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Alex
Well i want this to run generically within
a lot of stored procedures. I don't want
to have to hard code stored procedure
names and parameters

I was wondering if pass the parameter name as
a string whether sp_executeSql in the function
would be able to retrieve the value but
sp_executeSql won't run in a function.
Code:
SELECT    
	@Test = @Test + ',' + c.name + dbo.udfMyTest(c.name)
FROM      
	syscolumns c
	INNER JOIN sysobjects O On c.id = o.id

WHERE     
	o.id = @@procid
but it's a start

BlueCJH
 
If the query you posted works you simply need to add cast(@param as varchar) to the select list and concatenate it to your string. However, you will need to add the query to each proc. I think that anything that you could call generically would be just as much work, because you would need to pass it the SP name and all the parameters (plus you would need to write your procedure to handle for LOTS of different possibilities).

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top