Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
variables and table variables inside a cursor loop
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
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
View schema
Execution time: 0.02 sec, rows selected: 4, rows affected: 4, absolute service time: 0.2 sec
fork mode
|
history
|
discussion