asked on
CREATE PROCEDURE [dbo].[sp_Import]
as
SET NOCOUNT ON
-- Declare Variables
DECLARE
@TransactionID bigint,
@-------------
-- Declare Cursor for Cutomer Objects
DECLARE transaction_C_O CURSOR FOR
SELECT TransactionID,
FROM C_O h, M_C i
WHERE h.Status = 50
AND h.TransactionID = i.fk_TransactionID
ORDER BY TransactionID
OPEN transaction_C_O
FETCH NEXT FROM transaction_C_O
INTO @TransactionID, @..... other Attributes
WHILE (@@FETCH_STATUS = 0)
BEGIN --!!
BEGIN TRANSACTION
if (@F0bis = '2000-01-01')
BEGIN --!!
SET @F0bis = NULL
END --!
BEGIN --!!
if (@Command = 'DEC')
BEGIN --!!
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRANSACTION AA
if exists (SELECT Conditions)
BEGIN --!!
DELETE
FROM Table
WHERE condition
-----------------------
INSERT INTO Table (columns)
VALUES
(values)
-----------------------
UPDATE Table
SET statement
FROM Table
WHERE condition
END
else
BEGIN
--Something
END
COMMIT TRANSACTION --!
END
else
BEGIN
--Do something
END
END
COMMIT TRANSACTION
FETCH NEXT FROM transaction_C_O
INTO @TransactionID,--other columns
END --!
CLOSE transaction..
-- Count how many rows in update and set status done in the Primary key row
SET @Reco = (SELECT --Statement)
if (@RecordCount = @Reco)
BEGIN
UPDATE statement
END
else
BEGIN
UPDATE statement
END
DEALLOCATE transaction_..
ASKER
ASKER
ASKER
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY
ask yourself the question Why do I need to change the primary key and you will
find the real source of the problem..