June 23, 2006 at 8:48 am
Here is the command that I need to run
INSERT INTO #B SELECT TOP @TOPCNT FROM #A
My first problem is that I can't use a variable as the parameter in the TOP command.
I have tried putting the SQL into a variable and then using the EXEC (@command), but the EXEC can't reference local temporary tables.
Any suggestions?
June 23, 2006 at 8:58 am
Use 'set rowcount' in sql 2000...
http://www.aspfaq.com/show.asp?id=2521
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
June 23, 2006 at 9:01 am
You are correct, you cannot use a variable with TOP. Try this instead:
DECLARE @TopCnt int
SET @TopCnt = 100
SET ROWCOUNT @TopCnt
INSERT INTO #B
SELECT *
FROM #A
SET ROWCOUNT 0 --Make sure you set the RowCount back to zero!!
June 23, 2006 at 10:13 am
That worked thanks.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply