Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8383725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:13:58+00:00 2026-06-09T17:13:58+00:00

In a stored procedure (using SQL Server 2008 R2 SP2) is it possible to

  • 0

In a stored procedure (using SQL Server 2008 R2 SP2) is it possible to return a NewSequentialID() without a temp table variable?

I can successfully obtain the NewSequentialID() by using a temp table:

Getting Value of NEWSEQUENTIALID() on Insert

Perhaps I’m old school, but I try to refrain from using temp tables unless absolutely necessary… though this might be a case where it is absolutely necessary…

IF I try:

DECLARE @NewSequentialID UNIQUEIDENTIFIER;
SET @NewSequentialID = NEWID()

… it works as expected.

IF I try:

DECLARE @NewSequentialID UNIQUEIDENTIFIER;
SET @NewSequentialID = NEWSEQUENTIALID()

… I receive the following error:

The newsequentialid() built-in function can only be used in a DEFAULT
expression for a column of type ‘uniqueidentifier’ in a CREATE TABLE
or ALTER TABLE statement. It cannot be combined with other operators
to form a complex scalar expression.

  • Is the ONLY solution to use a temp table method?
  • Does anyone know of a reason why Microsoft implemented a difference between NEWSEQUENTIALID() to work like NEWID()?
  • Anyone know if there’s a chance Microsoft will update NEWSEQUENTIALID() to work like NEWID()?

Geo

UPDATE —
I’m not sure why Microsoft choose to implement the method in this manner, since they state that, “NEWSEQUENTIALID is a wrapper over the Windows UuidCreateSequential function”… but it appears that there is no non-temp-variable table method. (At least as of yet.)
Thanks for everyone’s comments / answers. [Moderator Note:] I’m not sure what to do with a question when the answer is “not possible”. So I’m going to give @marc_s credit for detailing a workaround.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:14:00+00:00Added an answer on June 9, 2026 at 5:14 pm

    For now – newsequentialid() can only be used as a default constraint on a column. That’s what the error message pretty clearly says, too.

    So in order to get your sequential GUID’s – you must have a table. No other way to do this. And no other way in SQL Server 2012, either.

    I have no idea nor any information as to why there’s such a difference, and why Microsoft chose to implement it this way….

    Update:

    OK, so you need to get that value that is being inserted into your table – how about using the OUTPUT clause?

    Something like:

    DECLARE @NewIDs TABLE (NewSeqID UNIQUEIDENTIFIER)
    
    INSERT INTO dbo.YourTable(list-of-columns)
    OUTPUT INSERTED.NewSeqID INTO @NewIDs(NewSeqID)
    VALUES (.........)
    

    This way, the output from the INSERT operation – the newly created sequential GUIDs – is being stored into that table variable, and you can use that, return it, slice it – whatever you like!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when debugging stored procedure using SQL server Management Studio 2008.
I am using SQL Server 2008 R2 and my stored procedure takes in a
I am using Sql Server 2008. My Stored Procedure accepts almost 150 parameters. Is
I'm using SQL Server 2008. I have an interesting scenario where a stored procedure
I am using SQL Server 2008 Enterprise. I am wondering whether this stored procedure
Using SQL Server 2008 I created a Stored Procedure called MyStoreProc and it runs
I'm writing a stored procedure in SQL Server 2008, interatively. When using SQL Server
Using SQL Server 2008, I have two stored procedures - create procedure [dbo].[SH_Export_data] (@unit
I'm using SQL Server 2008 . How can I pass Table Valued parameter to
Is it possible to take backup of database with stored procedure using Sql Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.