How to transfer data from a cursor to variables with a "fetch" statement?



How to transfer data from a cursor to variables with a "fetch" statement?..

Answer / Anand Kumar Jha

"To transfer data from a cursor to variables using the FETCH statement in MS SQL Server, you can use the DECLARE, OPEN, and FETCH statements. Here's an example:nnDECLARE @var1 INT;nDECLARE @var2 VARCHAR(50);nDECLARE myCursor CURSOR FOR SELECT col1, col2 FROM table_name;nOPEN myCursor;nFETCH NEXT FROM myCursor INTO @var1, @var2;..."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is the maximum size of column in sql server?

1 Answers  


what is lazy writer?

1 Answers   Wipro,


When do you use SQL Profiler?

3 Answers   Wipro,


Explain the use of containers in ssis?

1 Answers  


write the query for taking database backup in sql

10 Answers   ABC, IBM, Logica CMG, MA,


how do you implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql server database administration

1 Answers  


What is deadlock and how to avoid the deadlocks.

3 Answers   TCS, Wipro,


what are the disadvantages of cursors? : Sql server database administration

1 Answers  


How to list all field names in the result set using mssql_field_name()?

1 Answers  


What does sql server mean?

1 Answers  


Define ACID properties in a Database?

1 Answers   iNautix,


what is the Enterprise manager(2000) and management studio (2005)?

2 Answers  


Categories