Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bulk load method??
Message
De
21/04/2006 13:34:53
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01114251
Message ID:
01115502
Vues:
7
Can you think of any reason that a DTS package would not work with this? It does work when entering the data by hand, but I have not been able to get it to work when using DTS to import a table set.


>Try
>UPDATE tProducts
>    SET CurStockOnHand = CurStockOnHand + inserted.StockAdded - inserted.StockRemoved
>  FROM tProducts
>  JOIN inserted ON inserted.ProductID = tProducts.ProductID
>
>>I have the following code in a trigger which updates a filed in another table. I would like to be able to do bulk inserts without using a cursor, but am not sure how to do this in this case. Any and all help is very appriciated.
>>
>>====================================================
>>CREATE TRIGGER trUpdateCurrentStock ON dbo.tStockAvailable
>>FOR INSERT
>>AS
>>
>>DECLARE @ProductID INT,
>> @StockAvailID INT,
>> @CurrentStock INT
>>
>>SET @ProductID = (SELECT ProductID FROM INSERTED)
>>SET @StockAvailID = (SELECT StockAvailID FROM INSERTED)
>>
>>SET @CurrentStock = (SELECT CurStockOnHand FROM tProducts
>> WHERE ProductID = @ProductID) +
>> (SELECT StockAdded FROM INSERTED) -
>> (SELECT StockRemoved FROM INSERTED)
>>
>>UPDATE tProducts
>> SET CurStockOnHand = @CurrentStock
>> WHERE ProductID = @ProductID
>>=====================================================
>>
>>P.S. - tProducts and tStockAvailable are related by ProductID.
Thank You

Rollin Burr

Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform