I would like to build a sql statement that has a variable top command
that will go into a sp_executesql statement. Is this possible?
Something like
Thank you,
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
Code:
SELECT TOP @passedvalue * FROM mytable
Something like
Code:
create procedure usp_myproc
( @passedvalue INT)
AS
DECLARE @strsql NVARCHAR(1000)
DECLARE @params NVARCHAR(1000)
SET @strsql = N'SELECT TOP @pv column1, colum5 FROM mytable'
SET @params = N'@pv INT'
EXECUTE sp_executesql @strsql, @params, @pv = @passedvalue
Thank you,
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!