Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove ROWGUID designation on a PK column/key

I am attempting to strip a database of its current UID pks (while retaining the column) as part of a conversion process which will use all int keys.

SSMS 2008 (SQL Express 2008) - Database originally created in SQL 2000.
SQL 2008 full also installed if it helps.

A number of the tables have a UID pk which is ROWGUID=yes

It seems the ROWGUID designation is only found in the KEY properties. I can turn it off there but I'd like to do it as part of a script. If I do a SCRIPT TO on the key or the index I don't see anything indicating the column is a rowguid.

SMO still sees the column as a rowguid after the PK is dropped and the key and index no longer shows in SSMS.

I am a TSQL idiot, so feel free to speak slowly and use small words ;-)

Guidance appreciated. TIA

like image 934
Charles Hankey Avatar asked Dec 30 '22 05:12

Charles Hankey


1 Answers

Did you try:

ALTER TABLE dbo.<table>
  ALTER COLUMN <column>
  DROP ROWGUIDCOL;

If you're going to become proficient with altering tables via script (which is a great idea, since it is source controllable, much more repeatable and far less error-prone than using the UI), I'd bookmark the ALTER TABLE topic in Books Online.

like image 109
Aaron Bertrand Avatar answered Jan 13 '23 16:01

Aaron Bertrand