You are using global cursor that will be defined each time you are calling this procedure and give you the same error.
Define a local cursor. Just put the keyword LOCAL
after CURSOR
:
declare detailsCursor CURSOR LOCAL FOR
...
Related Contents:
- Can I loop through a table variable in T-SQL?
- Get Multiple Values in SQL Server Cursor
- SQL Server – Best way to get identity of inserted row?
- Should I use != or for not equal in T-SQL?
- Is it possible to specify condition in Count()?
- T-SQL Cast versus Convert
- How to DROP multiple columns with a single ALTER TABLE statement in SQL Server?
- Is there a performance difference between CTE , Sub-Query, Temporary Table or Table Variable?
- SQL RANK() versus ROW_NUMBER()
- When to use Common Table Expression (CTE)
- How do I create a foreign key in SQL Server?
- Changing the maximum length of a varchar column?
- Recover unsaved SQL query scripts
- Creating an index on a table variable
- How do I remove the first characters of a specific column in a table?
- How do you copy a record in a SQL table but swap out the unique id of the new row?
- How can I convert bigint (UNIX timestamp) to datetime in SQL Server?
- Can I create a One-Time-Use Function in a Script or Stored Procedure?
- IDENTITY_INSERT is set to OFF – How to turn it ON?
- alternatives to REPLACE on a text or ntext datatype
- COALESCE Function in TSQL
- How to get current instance name from T-SQL
- SQL Row_Number() function in Where Clause
- How do you update a DateTime field in T-SQL?
- SELECT FOR UPDATE with SQL Server
- How to get the identity of an inserted row?
- How do I return the SQL data types from my query?
- How to find column names for all tables in all databases in SQL Server
- ROW_NUMBER Without ORDER BY
- Update records in table from CTE
- Truncate/Clear table variable in SQL Server 2008
- Syntax for INSERTing into a table with no values?
- Most efficient way in SQL Server to get date from date+time?
- Insert multiple values using INSERT INTO (SQL Server 2005)
- What is the equivalent of the Oracle “Dual” table in MS SqlServer?
- Can I Comma Delimit Multiple Rows Into One Column? [duplicate]
- SQL Server: how to add new identity column and populate column with ids?
- How to get difference between two rows for a column field?
- Update if different/changed
- What is the difference between “;” and “GO” in T-SQL?
- What does =* mean?
- What’s the SQL national character (NCHAR) datatype really for?
- T-SQL: Selecting Column Based on MAX(Other Column)
- T-SQL split string based on delimiter
- DateTimeOffset.Now in T-SQL
- How can I INSERT data into two tables simultaneously in SQL Server?
- SQL: parse the first, middle and last name from a fullname field
- Sort by minimum value of two columns
- How to add a Try/Catch to SQL Stored Procedure
- MS SQL Date Only Without Time