Can someone with source control rights please integrate this patch?
It's getting very difficult to integrate by hand as the branche diverges.
Being that NewSequentialId is a SQL 2005 feature there should be no issue in using 2005 OUTPUT clause to support server generated sequential GUID's.
I have to wonder why this was never implemented before for any PK column with a default value. The following should occur:
[ for each PK column with a default value ]
DECLARE @PK_WITH_DEFAULT [TYPE]
SET @PK_WITH_DEFAULT = [DEFAULT_CODE]
[Build normal INSERT INTO clause]
[Augment VALUES clause to include temporary variables]
[Build SELECT statement for any generated key column (outputs)
e.g.
DECLARE @PK_WITH_DEFAULT UNIQUEIDENTIFIER
SET @PK_WITH_DEFAULT = (newsequentialid())
INSERT INTO [dbo].[Table]
(
[PK_WITH_DEFAULT]
,[COLOUMN_A]
,[COLOUMN_B]
)
VALUES
(
@PK_WITH_DEFAULT
,[COLOUMN_A]
,[COLOUMN_B]
)
SELECT @PK_WITH_DEFAULT
The output clause is nice in you don't have to declare a var and select it out, but honestly, being it's generated SQL who cares. The above concept would work for any server generated default, not just guid based ones. You could have some function calld fn_get_nex_raffle_id() and the above code would still work.