July 20, 2005 at 10:40 am
Is it possible to replace this:
DECLARE @sql varchar(255)
DECLARE @tablename varchar(255)
DECLARE @rcount int
set @sql = 'Select COUNT(*) as COUNT into ##TEMPCOUNT from ' + @tablename
EXECUTE sp_executesql @sql
SELECT @rcount = [COUNT] FROM ##TEMPCOUNT
with:
set @sql = 'Select ' + @rcount + ' = COUNT(*) as COUNT from ' + @tablename
EXECUTE sp_executesql @sql
and eliminate the temporary table creation?
July 20, 2005 at 11:08 am
Not possible. The variable @rcount is out of scope in Dynamic SQL.
May be steev's answers in this helps
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=202194#bm202408
Regards,
gova
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply