All Questions
88 questions
-1
votes
2
answers
161
views
Loop used to execute a procedure multiple times fails during nth run
I have the following code running a loop
DECLARE @table_name NVARCHAR(100)
, @sql NVARCHAR(MAX)
, @sp_name NVARCHAR(100)
, @rep_dt nvarchar(10)
, @min_rep_dt DATE
DECLARE mycursor CURSOR
LOCAL STATIC
...
0
votes
1
answer
1k
views
Update table using CURSOR and procedure result
I have stored procedure which returns a value and I want to loop all rows in table to update column. I'm using MSSQL.
I was planning to use CURSOR but I wasn’t able to get it work:
SELECT SeqNrColumn ...
0
votes
1
answer
2k
views
Is there a way to return a Stored Procedure Return_Value to the python script executing it?
I am writing a python script that should update a log table and notify me of it. Part of this script is to execute a SQL Server stored procedure.
I get an email telling me the status of the script as ...
0
votes
2
answers
53
views
Cursorfetch Error: Datatypes and number of variables match the select query
I'm facing issue When I calling this procedure from my main procedure. Error: Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.
ALTER PROCEDURE [ABC].[...
1
vote
2
answers
3k
views
Reading cursor in C# from SQL Server's CURSOR parameter of stored procedure
I have a stored procedure in Microsoft SQL Server that looks similar to this:
ALTER PROCEDURE [MySchema].[TestTable_MGR_RetrieveLaterThanDate]
@TestDate DATETIME,
@TableData CURSOR VARYING ...
0
votes
0
answers
80
views
How to prevent child from returning select in cursor (SQL Server)
I am trying to send one response back to an API from a SQL Server cursor.
The cursor calls a stored procedure that has a select in it.
declare db_cursor cursor for select
[item]
from someTable
open ...
0
votes
1
answer
294
views
Have to map XML data into a SQL table?
I'm getting XML data in my stored procedure and want to update the corresponding SQL Server table by mapping the values.
This is a sample of the XML:
DECLARE @xmlData XML = '<NewDataSet>
...
0
votes
1
answer
2k
views
CURSOR with a stored procedure with OUTPUT parameters
I have to insert one record at a time into a table and then execute a stored procedure by passing output variables.
The insert part actually does do the this and I see two different records into the ...
0
votes
1
answer
234
views
Cannot declare a cursor on SQL Server database
I have an issue with using a cursor in queries on two different databases. When I execute following query on one of them it returns "1" which means that the cursor is defined and when I execute it on ...
0
votes
0
answers
167
views
SQL query in stored procedure to update one table from another based on few calculations?
I am trying to create records from one table (MasterData) and insert new (multiple records) into another table (Orders) in MS SQL Server.
Initially I have been thinking of using cursors (in a stored ...
0
votes
2
answers
48
views
How do I make an algorithm to prioritize by date and / or source?
I'm little stuck with this algorithm that I have to do in sql.
I have in a table product codes, product name , supplier and the product update date.
I need to prioritize the products by provider and ...
1
vote
1
answer
112
views
Optimizing a stored procedure that uses cursor
There is a long running stored procedure. The 2nd table (visit) is used just for the results to be used in the where clause while retrieving records form the first table (approvals).
Below is the ...
0
votes
1
answer
1k
views
Cursor Not looping all the Records
I have created a stored procedure with a cursor to loop through a table which has the following records:
MTR EGA
----------------
NULL 110
NULL 111
NULL 121 ...
0
votes
3
answers
91
views
Values are not returned for Fromdate and ToDate columns
I have created a stored procedure for bulk invoice generation. On execution of the stored procedure, the values are successfully returned for all the columns except FromDate and ToDate. For these 2 ...
-2
votes
1
answer
500
views
Select Or Insert Data In Table Using Cursor
I am trying to pull one record at a time from a result set to use as value in Select Statement for Inserting data in Table.
select [Id]
from TBL
where PId = '123'
order by value
Result-set1
222
...