March 9, 2011 at 11:31 am
Need to add RowGUID column to tables and I'm running into some trouble. Not really familiar with all the uses of ALTER TABLE.
Attempting to execute this:
ALTER TABLE My_Table ADD [rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL
However, I'm sure I'm getting error messages because the column is being inserted as NULL values. So I want to give it a DEFAULT value I just don't know the best way or the syntax for that statement.
Suggestions? -Please help!
Thanks:-D
March 9, 2011 at 12:17 pm
Here's an example of how to do it:
CREATE TABLE My_Table (ID INT IDENTITY PRIMARY KEY);
GO
ALTER TABLE My_Table ADD [rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL DEFAULT (NEWID());
GO
DROP TABLE My_Table;
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 9, 2011 at 12:30 pm
Thank you!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply