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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 ROW Update

Author  Topic 

petek
Posting Yak Master

192 Posts

Posted - 2008-11-03 : 07:06:13
Hi All,


Hi i have a table without a unique row id but i need to add a column
in the table and make the row id unique is this possible??

Kind Regards

Pete.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-03 : 07:08:05
just use
ALTER TABLE tablenamehere ADD RowID int identity(1,1)
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-11-03 : 07:08:49
Sure:

ALTER TABLE tablename ADD MyUniqueID int NOT NULL IDENTITY(1, 1)

or

ALTER TABLE tablename ADD MyUniqueID uniqueidentifier NOT NULL DEAFULT(NewID())

- Lumbago
Go to Top of Page

petek
Posting Yak Master

192 Posts

Posted - 2008-11-03 : 07:08:56
i tried this

update HoldingtableNOMatch1 set ROWID = IDENTITY(1,1)

Kind Regards

Pete.
Go to Top of Page

petek
Posting Yak Master

192 Posts

Posted - 2008-11-03 : 07:12:51
I got the following error

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'DEAFULT'.


Kind Regards

Pete.
Go to Top of Page

petek
Posting Yak Master

192 Posts

Posted - 2008-11-03 : 07:14:49
Thankyou all it worked my bad....

Kind Regards

Pete.
Go to Top of Page
   

- Advertisement -