powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Добавление 2-х constraints
1 сообщений из 1, страница 1 из 1
Добавление 2-х constraints
    #32013843
George
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Мне нужно добавить 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
1 сообщений из 1, страница 1 из 1
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Добавление 2-х constraints
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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