Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Добавление 2-х constraints / 1 сообщений из 1, страница 1 из 1
11.09.2001, 11:42
    #32013843
George
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Добавление 2-х constraints
Мне нужно добавить 2 CONSTRAINT-a на таблицу.
Если делаю так
ALTER TABLE [dbo].[tCustomers] WITH NOCHECK ADD
CONSTRAINT [CK_tCustomers] CHECK (([cManagedAccount] = 'S' or [cManagedAccount] = 'Y') and [cParent] is null or [cManagedAccount] = 'N')
GO

ALTER TABLE [dbo].[tCustomers] WITH NOCHECK ADD
CONSTRAINT [PK_tCustomers] PRIMARY KEY CLUSTERED
(
[cCustCode]
) ON [PRIMARY]
GO

То все работает, а если так:


ALTER TABLE [dbo].[tCustomers] WITH NOCHECK ADD
CONSTRAINT [PK_tCustomers] PRIMARY KEY CLUSTERED
(
[cCustCode]
) ON [PRIMARY],
CONSTRAINT [CK_tCustomers] CHECK (([cManagedAccount] = 'S' or [cManagedAccount] = 'Y') and [cParent] is null or [cManagedAccount] = 'N')

GO

Получаю ошибки (это не опечатка, их действительно 4):

Server: Msg 433, Level 16, State 1, Line 1
Could not find CHECK constraint for 'dbo.tCustomers', although the table is flagged as having one.
Server: Msg 433, Level 16, State 1, Line 1
Could not find CHECK constraint for 'dbo.tCustomers', although the table is flagged as having one.
Server: Msg 433, Level 16, State 1, Line 1
Could not find CHECK constraint for 'dbo.tCustomers', although the table is flagged as having one.
Server: Msg 433, Level 16, State 1, Line 1
Could not find CHECK constraint for 'dbo.tCustomers', although the table is flagged as having one.


Поскольку код для добавления CONSTRAINT создал Enterprice Manager
а таких таблиц больше 20-ти, и исполнять подобный скрипт нужно регулярно,
то каждый Alter разбивать на 2 будет затруднительно
...
Рейтинг: 0 / 0
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Добавление 2-х constraints / 1 сообщений из 1, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]