Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Question on syntax..

Author  Topic 

pazzy11
Posting Yak Master

145 Posts

Posted - 2010-04-19 : 10:24:16
Hi ,
Using the OUTPUT clause I have the following code

DELETE FROM [Order Details]
OUTPUT deleted.* INTO OrderDetailsArchive
FROM Orders join [Order Details]
ON Orders.OrderID = [Order Details].OrderID
WHERE OrderDate < '12-01-1997';


This deletes all orders before 12-1-1997 and dumps
them into an archive table - but of course you can see that ;)

Anyway my question , with the
OUTPUT deleted.* INTO OrderDetailsArchive


the .* , this just means "all data" ? - in this case all data deleted ?


Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-19 : 10:34:29
yes -- all columns in the deleted set. (Imagine this is a trigger then the deleted table contains all the rows that were deleted).


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-19 : 10:34:45
It means all COLUMNS.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-19 : 10:35:36
This old rocker was too slow again.



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

pazzy11
Posting Yak Master

145 Posts

Posted - 2010-04-19 : 10:56:36
Thanks !"
Go to Top of Page
   

- Advertisement -