forum.venkateswarlu.net
      Register      Login
Sample Basic example about Cursors

1 replies to this topic

Kalyan Suman #1
Member
150 Points
Posted on 13 Jan 2015 08:18 PM IST

 HI i want to learn cursors i searched urls its seem to be difficult to practice i need basic cursor sample suppose employee ,student related tables

Thanks in Advance

Kalyan

 
SQL Server     798 views     Reply to this topic
Laxman B #2
Member
42 Points
Replied on 11 Jun 2015 02:25 PM IST
DECLARE Send_DBMailCursor CURSOR FAST_FORWARD READ_ONLY FOR
SELECT  Name,ID from <Table Name>
 
OPEN Send_DBMailCursor
FETCH NEXT FROM Send_DBMailCursor INTO  @NAME,@ID
   
WHILE @@FETCH_STATUS = 0
BEGIN
// write your code
FETCH NEXT FROM Send_DBMailCursor INTO  @NAME,@ID
END
CLOSE Send_DBMailCursor
DEALLOCATE Send_DBMailCursor
 
Reply to this topic