?
Solved

Alter existing UNIQUEIDENTIFIER column to make it the ROWGUID

Posted on 2005-04-06
2
Medium Priority
?
491 Views
Last Modified: 2011-04-15
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
Comment
Question by:jasww
2 Comments
 
LVL 17

Accepted Solution

by:
BillAn1 earned 1000 total points
ID: 13716813
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
 

Author Comment

by:jasww
ID: 13716920
Rock and roll.

Perfect.

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

Thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question