Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to put OUTPUT
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01673317
Message ID:
01673318
Views:
40
>Hi,
>
>Where do you put an OUTPUT command in a SQL Update of the following "structure"?
>
>
>update t1 set @Qty2Use = case when t1.qty_left >= @QtyUseRemain then @QtyUseRemain else t1.qty_left end,  
>t1.qty_left = t1.qty_left - @Qty2Use
>from #InvStockTemp t1 inner join (select top (1) ......
>.....
>
>
>I declared the temp variable as follows:
>
>DECLARE @UpdateOutput table
>(
>  QtyLeftOld int,
>  QtyLeftNew int
>);
>
>
>But when I put the OUTPUT right before FROM #InvStockTemp, I get an error.
>
>Where do I put it?
>
>TIA

See sample E in this https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver15
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform