How to seed or increment NEWID() value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sujathaeeshan
    New Member
    • Feb 2008
    • 22

    How to seed or increment NEWID() value

    Hi all,

    Newid() which creates a unique value of type uniqueidentifie r.

    Is there any possibolities for seeding or incrementing the NEWID() value.

    For example:

    create table cust(cust_id uniqueidentifie r NOT NULL
    DEFAULT newid(),cust_na me varchar(60) NOT NULL)

    For insertion example:
    INSERT cust (cust_id, contact_name) VALUES (newid(), ' ABC ' )
    INSERT cust (cust_id, contact_name) VALUES (newid(),' XYZ ' )
    INSERT cust (cust_id, contact_name) VALUES (newid(), ' PQR ' )
    If i am inserting more then one row detail NEWID() creates uniquevalue.

    But i want to increment the NEWID() value is that possible!!!

    Plz...can anyone help
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by sujathaeeshan
    Hi all,

    Newid() which creates a unique value of type uniqueidentifie r.

    Is there any possibolities for seeding or incrementing the NEWID() value.

    For example:

    create table cust(cust_id uniqueidentifie r NOT NULL
    DEFAULT newid(),cust_na me varchar(60) NOT NULL)

    For insertion example:
    INSERT cust (cust_id, contact_name) VALUES (newid(), ' ABC ' )
    INSERT cust (cust_id, contact_name) VALUES (newid(),' XYZ ' )
    INSERT cust (cust_id, contact_name) VALUES (newid(), ' PQR ' )
    If i am inserting more then one row detail NEWID() creates uniquevalue.

    But i want to increment the NEWID() value is that possible!!!

    Plz...can anyone help

    I believe newid() returns a varchar. What do you mean increment? Maybe an IDENTITY column will solve your problem, not a uniqueidentifie r datatype.

    -- CK

    Comment

    Working...