views:

28

answers:

1

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

+1  A: 

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.

Aaron Bertrand
Blush. Thanks so much Aaron. I think I had brain-freeze. Googled my head off, poked around in ssms and forgot the most basic set of docs. DOH!as a followup - is there a generic way to identify in looping through an entire database where the rowguids are - IOW will I throw an error (and stop looping) if I try to drop a rowguidcol that isn't a rowguidcol?
Charles Hankey
Sure, your cursor could use: SELECT table = OBJECT_NAME(object_id), column = name FROM sys.columns WHERE is_rowguidcol = 1; ... TRY/CATCH wouldn't be a bad idea either, in case there are situations where the property can't be dropped.
Aaron Bertrand
Thanks once again, Aaron. That looks like exactly what I'll need.
Charles Hankey