2
CREATE TABLE publishers
(
    PublisherName    varchar(75),
    City                    varchar(35),
    PublisherState    char(2),
    Country            varchar(4)
)
GO 

-- modify publishers so that state must be two letters

ALTER TABLE publishers
    ALTER COLUMN publisherstate char(2) CHECK (publisherstate LIKE '[A-Za-z][A-Za-z]')​
zeezoo500
  • 23
  • 5

1 Answers1

1

You have to mention the Constraint Name and Check.

Try this:

alter table publishers
add constraint codeCheck check (PublisherState like '[A-Za-z][A-Za-z]');
DineshDB
  • 5,998
  • 7
  • 33
  • 49