Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql server loop over query

DECLARE @id INT
DECLARE @name NVARCHAR(100)
DECLARE @getid CURSOR

SET @getid = CURSOR FOR
SELECT table.id,
       table.name
FROM   table

OPEN @getid
FETCH NEXT
FROM @getid INTO @id, @name
WHILE @@FETCH_STATUS = 0
BEGIN
    EXEC stored_proc @varName=@id, @otherVarName='test', @varForName=@name
    FETCH NEXT
    FROM @getid INTO @id, @name
END

CLOSE @getid
DEALLOCATE @getid
Comment

PREVIOUS NEXT
Code Example
Sql :: how to delete a column in sql 
Sql :: mysql substract count and distinct count 
Sql :: last 6 months postgresql 
Sql :: how to get table structure in sql server 
Sql :: how to change owner in postgres 
Sql :: postgresql add alter permissions to role 
Sql :: alter table change default 
Sql :: group concat with separator 
Sql :: mysql search like order by best match 
Sql :: oracle update with sequence 
Sql :: mysql with rollup 
Sql :: postgres list tables and row counts 
Sql :: postgresql list columns 
Sql :: Configure MYSQL to run on another port number, other than the default port 3306 ubuntu linux 
Sql :: mysql select last row for each group 
Sql :: MySql get primary keys of table 
Sql :: sql alchemy with azuresql server 
Sql :: query concatenate 
Sql :: mysql persistence.xml 
Sql :: SELECT NUMBER OF rows for all tables oracle 
Sql :: use of now() in mysql 
Sql :: mysql python 
Sql :: ora-02391 
Sql :: sql create table if not exists 
Sql :: oracle undo usage by session 
Sql :: mysql limit offset 
Sql :: postgresql update between 2 tables 
Sql :: coalesce postgresql 
Sql :: insert data in pgsql 
Sql :: order by oracle 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =