Search

Allow variable assignment using DML OUTPUT clause by Adam Machanic

Closed
as Won't Fix Help for as Won't Fix

21
0
Sign in
to vote
Type: Suggestion
ID: 150944
Opened: 6/28/2006 10:25:43 PM
Access Restriction: Public
0
Workaround(s)
The OUTPUT clause added to the DML statements is quite useful as-is, but would be even better if it could be used for variable assignment. There is an issue of multi-row operations, but I think it could behave similarly to variable assignment using SELECT in those cases (i.e., which row would end up assigning to the variables would be nondeterministic).

This would be really great for single-row operations, when a temp table/table variable is really overkill as we just need to assign a couple of values from the affected rows to some variables.
Details (expand)
Product Language
English
Version
SQL Server 2005 - Developer Edition (32)
Category
SQL Engine
Operating System
Windows XP SP2 Professional
Operating System Language
English
Proposed Solution
I'd like to be able to do this:

CREATE TABLE x1
(
    col UNIQUEIDENTIFIER DEFAULT(NEWSEQUENTIALID())
)
GO

DECLARE @y UNIQUEIDENTIFIER

INSERT x1
OUTPUT @y = inserted.col
DEFAULT VALUES
GO
Benefits
Faster Development
Improved Performance
Other Benefits
Mainly, performance -- no need for table variables or temp tables
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 10/10/2006 at 6:25 PM
Dear Adam

Thanks for your suggestion. The product team is currently investigating your request for this functionality and may consider it for a future release.

Best regards
Michael
Sign in to post a workaround.