April 15, 2011 at 1:01 am
Hi All,
I have created a dynamic statement using sp_executesql but i am getting below error on execution.
Error:
Could not find stored procedure 'SELECT @TDATA=COUNT(*) FROM TBL_Q6310'.
Statement inside stored procedure
SET @SQLString = N'SELECT @TDATA=COUNT(*) FROM '+@QName
EXEC dbo.sp_executesql
@query = @SQLString,
@params = N'@TDATA INT OUTPUT',
@TDATA = @TDATA OUTPUT
Please guide me how can i resolve this issue.
Thanks!
Shatrughna
Shatrughna
April 15, 2011 at 6:38 am
Try this
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);
DECLARE @TDATA varchar(30);
declare @QName varchar(50)='TBL_Q6310'
SET @SQLString = N'SELECT @TDATAOUT = Count(*) FROM '+@QName
SET @ParmDefinition = N' @TDATAOUT varchar(30) OUTPUT';
print @SQLString
print @ParmDefinition
EXECUTE sp_executesql @SQLString, @ParmDefinition, @TDATAOUT=@TDATA OUTPUT;
SELECT @TDATA;
Thanks
Parthi
April 15, 2011 at 6:57 am
Thanks Parthi for your valuable effort.
I got the solution.
Thanks!
Shatrughna
Shatrughna
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply