Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to start unique identifier in sql server 2005

Author  Topic 

feejaz
Yak Posting Veteran

68 Posts

Posted - 2009-06-13 : 01:32:04
Hi every one,

I want to start the table's unique identifier from 1. There was thousands of row in the table that I have just deleted to start from 1.
Please let me know the query to start the unique identifier from 1.

regards,

feejaz

Navi

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-13 : 03:09:48
A UNIQUEIDENTIFIER doesn't "start" with 1.

Do you mean an IDENTITY column, or a sequential UNIQUEIDENTIFIER?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-14 : 01:33:49
quote:
Originally posted by feejaz

Hi every one,

I want to start the table's unique identifier from 1. There was thousands of row in the table that I have just deleted to start from 1.
Please let me know the query to start the unique identifier from 1.

regards,

feejaz

Navi


uniqueidentifier stores GUID values. as per your requirement what you need is a identity column which starts from 1. in that case, just use below

ALTER TABLE yourtable ADD IDCol int IDENTITY(1,1)
Go to Top of Page

jeffreymfischer
Starting Member

10 Posts

Posted - 2009-10-07 : 11:12:29
I've written a detailed article on an enterprise-ready unique identifier solution.

http://blog.scoftware.com/post/2009/08/29/SQL-Server-UniqueIdentifier-Globally-Unique-Globally-Sequential-SOLUTION.aspx

Read it and provide feedback.

Jeff Fischer

Scoftware Achitect/Developer
http://blog.scoftware.com

Scoftware Achitect/Developer
http://blog.scoftware.com
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-07 : 11:47:41
feedback....sure

If you used natural keys, then it would never be an issue



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jeffreymfischer
Starting Member

10 Posts

Posted - 2009-10-13 : 03:37:42
Refer to my blog for help using SQL Server's uniqueidentifier data type.

[url]http://blog.scoftware.com/post/2009/08/29/SQL-Server-UniqueIdentifier-Globally-Unique-Globally-Sequential-SOLUTION.aspx[/url]

Jeff Fischer
Go to Top of Page
   

- Advertisement -