How to Turn Rowguid option on via SQL Query?

How do I turn Rowguid option on (= Yes), when I create a table via SQL Query?

(See SQL Server Management Studio, Column properities , Rowguid by default is no).


Test Query Attached.
create table TableA (TableAID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, TableBID int null, constraint PK_TableA primary key (TableAID));
create table TableB (TableBID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, constraint PK_TableB primary key (TableBID));
create table TableA2 (TableA2ID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, TableBID int null, constraint PK_TableA2 primary key (TableA2ID));
create table TableB2 (TableB2ID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, constraint PK_TableB2 primary key (TableB2ID));
create table TableA3 (TableA3ID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, TableB3ID int null, constraint PK_TableA3 primary key (TableA3ID));
create table TableB3 (TableB3ID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, constraint PK_TableB3 primary key (TableB3ID));
create table TableA4 (TableA4ID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, constraint PK_TableA4 primary key (TableA4ID));
create table TableB4 (TableB4ID int identity not null, Name varchar(50) null, rowguid uniqueidentifier default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, constraint PK_TableB4 primary key (TableB4ID));
create table TableA4_TableB4 (TableA4ID int not null, TableB4ID int not null, primary key (TableA4ID, TableB4ID));
alter table TableA add constraint FKTableA_TableB foreign key (TableBID) references TableB;
alter table TableA2 add constraint FKTableA2_TableB2 foreign key (TableBID) references TableB2;
alter table TableA3 add constraint FKTableA3_TableB3 foreign key (TableB3ID) references TableB3;
alter table TableA4_TableB4 add constraint FKTableA4TableB4_TableA4 foreign key (TableA4ID) references TableA4;
alter table TableA4_TableB4 add constraint FKTableA4TableB4_TableB4 foreign key (TableB4ID) references TableB4;

Open in new window

KhouAsked:
Who is Participating?
 
dportasConnect With a Mentor Commented:
ROWGUIDCOL:

create table TableA (TableAID int identity not null, Name nvarchar(50) not null, rowguid uniqueidentifier ROWGUIDCOL default (newid()) not null unique, ModifiedDate datetime default (getdate()) not null, TableBID int null, constraint PK_TableA primary key (TableAID));
0
 
KhouAuthor Commented:
Thanks Dportas
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.

All Courses

From novice to tech pro — start learning today.