About 1,010,000 results
Open links in new tab
  1. sql - How to check if cursor exists (open status) - Stack Overflow

    Feb 11, 2016 · Just to add: if you use the cursor stored in local variable declared somewhere in the script (e.g. DECLARE @cursorName CURSOR ) use appropriate cursor type ('variable') when …

  2. Using a cursor with dynamic SQL in a stored procedure

    A cursor will only accept a select statement, so if the SQL really needs to be dynamic make the declare cursor part of the statement you are executing. For the below to work your server will have to be …

  3. Why is it considered bad practice to use cursors in SQL Server?

    Dec 22, 2021 · Even the fast forward cursor in Sql Server 2005 can't compete with set-based queries. The graph of performance degradation often starts to look like an n^2 operation compared to set …

  4. Is there any way to get a list of open/allocated cursors in SQL server ...

    Dec 25, 2021 · Then subsequent runs fail when it tries to create cursors since a cursor with the name already exists. Is there a way I can query which cursors exists and if they are open or not so I can …

  5. sql - Cursor not open - Stack Overflow

    Mar 15, 2013 · I'm trying to create table using statements stored in table. I'm using a cursor with execute(sql) as below: create table tab ( CreateSql varchar(250) ) insert into tab values ('create table …

  6. What is the use of a cursor in SQL Server? - Stack Overflow

    Sep 25, 2018 · To use cursors in SQL procedures, you need to do the following: 1.Declare a cursor that defines a result set. 2.Open the cursor to establish the result set. 3.Fetch the data into local variables …

  7. sql - Open and Close Cursors Inside or Outside a Transaction and How …

    Jan 20, 2014 · I am writing a stored procedure in SQL Server 2012 that uses a cursor for reading and a transaction inside a TRY CATCH block. Basically, my questions are as follows: Should I declare my …

  8. sql server - What happens when you forget to close and deallocate ...

    Aug 6, 2014 · 37 Leaving cursor open is known as a bad practice. But what really happens when you forget to close and/or deallocate it? How does it affect SQL Server, connection/session? Are there …

  9. t sql - T-SQL: A proper way to CLOSE/DEALLOCATE cursor in the …

    Sep 11, 2009 · If you want to learn more about cursors in SQL Server, I highly recommend reading this blog post on the subject, as he goes into great detail explaining what the various modifiers of a …

  10. sql server - Can I reset cursor's position to the beginning? - Stack ...

    Jun 26, 2013 · As in the topic. Can I simply reset cursor's position to the beginning in Transact-SQL, so it can run again over the table? I want to reset it in the following context: DECLARE @userID INT …