sql,foreach,loop

Mark 7/27/2016 0

this is an sql code for foreach loop

Transact-SQL
DECLARE @adminid int

DECLARE MemberCursor CURSOR
  LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR
SELECT Id
FROM Member where CompanyId=1 and RoleId in (1 ,2, 3)

OPEN MemberCursor
FETCH NEXT FROM MemberCursor INTO @adminid
WHILE @@FETCH_STATUS = 0
BEGIN
    PRINT @adminid
    FETCH NEXT FROM MemberCursor INTO @adminid
END
CLOSE MemberCursor
DEALLOCATE MemberCursor
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments