DECLARE @rCounts int,@i int
SET @rCounts=(SELECT COUNT(*) FROM tbSide)
SET @i=0
WHILE @i<@rCounts
BEGIN
SET @i=@i+1
PRINT 'INSERT INTO tbSide SELECT TOP '+@i+' * FROM tbSide'
END
Server: Msg 245, Level 16, State 1, Line 7
Syntax error converting the varchar value 'INSERT INTO tbSide SELECT TOP ' to a column of data type int.
DECLARE @rCounts int,@i int
SET @rCounts=(SELECT COUNT(*) FROM table1)
SET @i=0
WHILE @i<rCounts
BEGIN
SET @i=@i+1
PRINT 'INSERT INTO table1 SELECT TOP '+@i+' * FROM table1'
END