How to write new column with check constraint to allow only values Y, N ?
Asked
Active
Viewed 280 times
0
-
1@Mureinik SQL Server. – Bugs_Bunny_In_Sky Jul 03 '20 at 20:23
-
2You need to provide a minimal code to reproduce the problem. See more details on how to post a question at this link: https://stackoverflow.com/help/minimal-reproducible-example – Usama Abdulrehman Jul 03 '20 at 20:30
1 Answers
2
An alter table
statement should do it:
ALTER TABLE mytable
ADD newcolumn CHAR(1) NOT NULL DEFAULT 'N' CHECK (newcolumn IN ('Y', 'N'))

Mureinik
- 297,002
- 52
- 306
- 350