A Cursor Sample with Two Variables and Default datetime


  


declare @invoiceid int , @col int
declare @dt datetime =current_timestamp


--declare local fast_forward cursor
DECLARE the_cursor CURSOR local fast_forward  FOR 
		

Select invoiceid, col from atable


OPEN the_cursor 

FETCH NEXT FROM the_cursor INTO @invoiceid, @col 
		 

		WHILE @@FETCH_STATUS = 0
		BEGIN

 ---do somthing here to use the two variables and @dt if needed for timestamp


 FETCH NEXT FROM the_cursor INTO   @invoiceid, @col ;

 END
		
		
 CLOSE the_cursor;
 DEALLOCATE the_cursor;



 
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s