create table #tempWhile
(
[Id] int
,[name] nvarchar(200)
)
insert into #tempWhile values (1,'test1')
insert into #tempWhile values (3,'test3')
insert into #tempWhile values (4,'test4')
insert into #tempWhile values (5,'test5')
-----------------------------------
Declare @id nvarchar(200)
Declare @name nvarchar(200)
-----------------------------------
select Identity(int,1,1) id1, *
into #temp2
from #tempWhile ORDER BY id
----
Declare @count Int
Declare @LoopCount Int
set @count = @@rowcount
set @LoopCount = 1
-----
while @LoopCount <= @count
begin
select @id=id1,@name=name from #temp2 where id = @LoopCount
print 'Name: '+@name+' || ID: '+ @id
-------
set @LoopCount = @LoopCount + 1
end
--------------------------------
Drop table #tempWhile
Drop table #temp2
(
[Id] int
,[name] nvarchar(200)
)
insert into #tempWhile values (1,'test1')
insert into #tempWhile values (3,'test3')
insert into #tempWhile values (4,'test4')
insert into #tempWhile values (5,'test5')
-----------------------------------
Declare @id nvarchar(200)
Declare @name nvarchar(200)
-----------------------------------
select Identity(int,1,1) id1, *
into #temp2
from #tempWhile ORDER BY id
----
Declare @count Int
Declare @LoopCount Int
set @count = @@rowcount
set @LoopCount = 1
-----
while @LoopCount <= @count
begin
select @id=id1,@name=name from #temp2 where id = @LoopCount
print 'Name: '+@name+' || ID: '+ @id
-------
set @LoopCount = @LoopCount + 1
end
--------------------------------
Drop table #tempWhile
Drop table #temp2
No comments:
Post a Comment