Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server getting values for CHECK

Tags:

sql

sql-server

Is there a way to get the values for a CHECK Constraint

Example

CONSTRAINT TheCollumn CHECK (TheCollumn IN('One','Two','Three') )

I want to get the 'One' 'Two' 'Three' from a Query which I can then use to populate a Dropdown without having to retype the values in the dropdown list

like image 653
Donald Jansen Avatar asked Aug 30 '25 18:08

Donald Jansen


1 Answers

I think you want a foreign key constraint and a reference table:

create table refTheColumn (
    name varchar(255) primary key
);

. . .
    constraint fk_thecolumn foreign key (theColumn) references refTheColumn(name);

Then you can populate the list with the reference table.

like image 66
Gordon Linoff Avatar answered Sep 02 '25 07:09

Gordon Linoff