Blog Pages

OUTPUT


-- INSERT INTO.... OUTPUT INSERTED
INSERT INTO HR.Staff ( FirstName, LastName )
OUTPUT INSERTED.StaffID, DATEADD(d,90,GETDATE()),'90-Day Review'
INTO HR.Notification
    (
        StaffID,
        NotificationDate,
        NotificationType
    )
VALUES  ( 'Santa','Claus')
-- UPDATE .... OUTPUT
UPDATE Production.Document
SET DocumentSummary .WRITE (N'features',28,10)
OUTPUT deleted.DocumentSummary, 
       inserted.DocumentSummary 
    INTO @MyTableVar
WHERE Title = N'Front Reflector Bracket Installation'

-- save the results of a DELETE statement into a table variable
DELETE Sales.ShoppingCartItem
OUTPUT DELETED.* 
WHERE ShoppingCartID = 20621

No comments:

Post a Comment