SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Similar Functionality To @@IDENTITY

Last post 09-03-2008, 23:50 by NeverDie. 4 replies.
Sort Posts: Previous Next
  •  09-03-2008, 21:43 14511

    Similar Functionality To @@IDENTITY

    ...and I don't mean SCOPE_IDENTITY() Big Smile

    How can I get the value of the last UNIQUEIDENTIFIER inserted into a table with a DEFAULT value of NewSequentialID. I was hoping to find a built in function of sorts to give me the value as opposed to SELECTing it of the table itself.


    A Program is only Complete when the Programmer Dies
  •  09-03-2008, 21:50 14512 in reply to 14511

    Re: Similar Functionality To @@IDENTITY

    No built-in function for that. You can use the OUTPUT clause though.

    Gail Shaw - SQL In the Wild
    SQL Server MVP
    --
    Chaos, panic and disorder. My job here is done!
  •  09-03-2008, 23:26 14514 in reply to 14512

    Re: Similar Functionality To @@IDENTITY

    How do you use the OUTPUT clause when inserting into a table.


    A Program is only Complete when the Programmer Dies
  •  09-03-2008, 23:43 14515 in reply to 14514

    Re: Similar Functionality To @@IDENTITY

    2005 or 2008?

    2005, output into a table variable and insert from there into the table (messy, but...)
    2008, you can (I hear) insert directly from the output of one into another table. (note to self, need to figure it out and blog)


    Gail Shaw - SQL In the Wild
    SQL Server MVP
    --
    Chaos, panic and disorder. My job here is done!
  •  09-03-2008, 23:50 14517 in reply to 14515

    Re: Similar Functionality To @@IDENTITY

    Thanks Gila.

    Our production environments are 2005.

     


    A Program is only Complete when the Programmer Dies
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems