July 25, 2005 at 4:26 pm
Hi,
I've the following dynamic SQL stmt.
SET @strSQL = N'SET @RSCCount=Select Count(*) From tblRepNK'
Where @RSCCount is an output parameter in a stored procedure. How do i execute it using sp_executesql @strSQL .
TIA
July 25, 2005 at 10:42 pm
EXEC('sp_executesql ' + @strSQL)
Hope this works
Charles Wilkinson
Database Administrator
Sastek Pty Ltd
www.sastek.com
July 26, 2005 at 6:45 am
Sorry it still does not work. I hope you understood the problem. I want no. of rows returned by count(*) in the @RSCCount output parameter.
Thanks for your time.
July 26, 2005 at 9:25 am
EXEC('sp_executesql ' + @strSQL) will set the value of @RSC
add this line
print @RSC
July 26, 2005 at 9:40 am
DECLARE @LiveRowCount BIGINT,
@SqlCmd NVARCHAR(4000)
SET @SqlCmd = 'SELECT @RowCount = COUNT(*) FROM ' + QUOTENAME(@MyTableName)
EXEC sp_executesql @SqlCmd, N'@RowCount BIGINT OUT', @LiveRowCount OUT
IF @LiveRowCount > 0
PRINT 'Row count = ' + CAST(@LiveRowCount AS VARCHAR)
Hope this helps
Wayne
July 26, 2005 at 10:48 am
Hi Wayne,
U R Awesome.
Thanks a lot for your time.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply