• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

Alter existing UNIQUEIDENTIFIER column to make it the ROWGUID

How do I, from within a proc, alter an exisiting table to make the PK column also the ROWGUID column?
I cannot see any way of doing it without dropping the column and recreatiing it with this constraint.

It must be possible to turn a column intoa ROWGUID column without dropping and remaking the column, because Enterprise Manager is able to do so with the IsRowGuid flag.

Thanks
Daniel
JASWW
0
jasww
Asked:
jasww
1 Solution
 
BillAn1Commented:
try following this :

create table MyTable (a uniqueidentifier, b integer
constraint PK_MyTable primary key clustered (a)
)
go
alter table dbo.MyTable alter column a add ROWGUIDCOL
go
alter table dbo.MyTable add constraint DF_MyTable_a default (newid()) for a
0
 
jaswwAuthor Commented:
Rock and roll.

Perfect.

God don't you love T-SQl and it's oh-so-easy syntax?

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now