Question : How can I  set a GUID column to ROWGUID using T-SQL?

I have a source table with a primary key column that is a guid and is set as rowguid when the table was created.  I want to duplicate this table using a select-into command and then perform some actions on it and then drop the original table and rename this clone to the name of the original and continue.  I can use T-SQL to add the indexes and defaults back to the table but I can't figure out the syntax to set the column back to ROWGUID.  Does anyone know how to do it?

Answer : How can I  set a GUID column to ROWGUID using T-SQL?

This should do what you're after :o)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.tablename ALTER COLUMN columnname
	ADD ROWGUIDCOL
GO
COMMIT
Random Solutions  
 
programming4us programming4us