February 14, 2007 at 11:08 pm
I am adding constraint to a table in Sql server 2000 using query for eg.
alter table test add test1 bit not null default 0
but this will introduce some alphanumeric characters in constraint name shown in red color below.
ALTER TABLE test DROP CONSTRAINT [DF__test__Field__3CAF821C]
but if i am doing this through enterprise manager simply column name is there in constraint name.
ALTER TABLE test DROP CONSTRAINT [DF__test__test1]
when i am running the script to drop the constarint & the column it will works fine in the latter case. but in former case each time different alphanumeric characters are generated.
so i cannot drop that constraint because each time a different constraint name is there.
can anyone help me out whys is it so..?
thx in advance
February 15, 2007 at 2:36 am
SQL Server, under certain circumstances (eg CREATE / ALTER table), when generating constraint / key names, will add characters (like your example) to names to make sure they're unique
To avoid this specifiy the name you require during the CREATE / ALTER
ALTER TABLE [test] ADD test1 bit not null CONSTRAINT [DF__test__test1] DEFAULT (0)
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply