December 22, 2003 at 12:37 am
I tried the 'right' answer and it gave me this error:
Server: Msg 3728, Level 16, State 1, Line 1
'MyConstraint' is not a constraint.
The last answer did the trick. Any explanation, anyone?
Regards,
Hans Brouwer
Kind regards,
Hans Brouwer
Greetz,
Hans Brouwer
December 22, 2003 at 12:48 am
Further more, after creating the table with the script provided in the question, I could not find a constraint in the table. I scripted the table back and this is what I got:
CREATE TABLE [dbo].[MyTable] (
[Pk] [int] NOT NULL ,
[Choice] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
No default value...while looking in the table in designmode the constraint was there, and worked.
I tried this on a desktopversion of SQL Server, sp3. Does this has siomething to do with configuration? I am really curious about this.
Regards,
Hans Brouwer
Kind regards,
Hans Brouwer
Greetz,
Hans Brouwer
December 22, 2003 at 3:30 am
I don't see anything wrong with this question. I ran the original CREATE TABLE script and it created the table fine, with a default value of 'Old' for the Choice column. I then ran the two ALTER TABLE statements as per the correct answer and the default value for the column changed to 'New' which was the desired effect.
Edited by - jameslean on 12/22/2003 04:22:52 AM
-----
JL
December 22, 2003 at 4:03 am
I'm puzzled why it's not working for you. I just tested it against 3 machines and it worked each time. The 5th example would work, however it would have a negative effect on your production while data was copied out and back in. That leaves 4 as the only possible answer.
Brian Knight
http://www.sqlservercentral.com/columnists/bknight
Brian Knight
Free SQL Server Training Webinars
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply