Connecting Tech Pros Worldwide Help | Site Map

How to seed or increment NEWID() value

sujathaeeshan's Avatar
Newbie
 
Join Date: Feb 2008
Posts: 19
#1: Feb 18 '08
Hi all,

Newid() which creates a unique value of type uniqueidentifier.

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

For example:

create table cust(cust_id uniqueidentifier NOT NULL
DEFAULT newid(),cust_name 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's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Feb 18 '08

re: How to seed or increment NEWID() value


Quote:

Originally Posted by sujathaeeshan

Hi all,

Newid() which creates a unique value of type uniqueidentifier.

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

For example:

create table cust(cust_id uniqueidentifier NOT NULL
DEFAULT newid(),cust_name 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 uniqueidentifier datatype.

-- CK
Reply


Similar Microsoft SQL Server bytes