About 474,000 results
Open links in new tab
  1. 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 …

  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 …

  3. sql - Using a cursor with a CTE - Stack Overflow

    Jan 30, 2013 · I need a cursor for the below query so I can loop through to fetch/update/insert some other data. Can somebody help me with this? DECLARE @FROMDATE DATETIME …

  4. Define Cursor with Dynamic Table Name in SQL Server

    Jan 9, 2020 · 1 DECLARE cursor1 CURSOR LOCAL FOR SELECT ORDER_ID FROM @TableName1 OPEN cursor1 FETCH next FROM cursor1 INTO @ORDER_ID WHILE …

  5. Get Multiple Values in SQL Server Cursor - Stack Overflow

    93 I have a cursor containing several columns from the row it brings back that I would like to process at once. I notice most of the examples I've seeing on how to use cursors show them …

  6. sql server - T-SQL: Looping through an array of known values

    Declare @Id Integer = 0 -- assuming all Ids are > 0 While exists (Select * From @Ids where id > @Id) Begin Select @Id = Min(id) from @Ids Where id > @Id exec p_MyInnerProcedure @Id …

  7. Advantages on using cursor variable in SQL Server (declare @cn …

    Jun 6, 2013 · On the other hand, If DECLARE @local_variable CURSOR is used to define the cursors in the parent and child stored procedures, then @local_variable is local to each …

  8. Is there a way to use parameters in a SQL Server cursor?

    I tried this and found that the contents of the cursor does not change if you close the cursor, change the value in the variable, and then reopen the cursor. It appears that the cursor …

  9. SQL Server Fast Forward Cursors - Stack Overflow

    While a fast forward cursor does have some optimizations in Sql Server 2005, it is not true that they are anywhere close to a set based query in terms of performance. There are very few …

  10. sql server - If-Else Condition inside cursor - Stack Overflow

    Mar 13, 2017 · Declare CursorName CURSOR FOR Select Query Now the select query would contain an If-Else Condition.