Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
variables and table variables inside a cursor loop
declare @id int DECLARE i CURSOR FAST_FORWARD LOCAL FOR select Id from Pilots OPEN i FETCH NEXT FROM i INTO @id WHILE (@@fetch_status = 0) BEGIN --every time I do this I make this same mistake declare @table_variable table ( id int ) insert into @table_variable(ID) select @id --with new iteration table content is not erased (same with scalar variables) !!!! --delete from @table_variable --do this select count(*) from @table_variable FETCH NEXT FROM i INTO @id END CLOSE i DEALLOCATE i
run
|
edit
|
history
|
help
0
sarthak rana
Uzd
Task_7_Final
Cte recursion
table creation
RH
bc160401693
MindBoxTest(A.M.)
BT SQL Project
megha