sql server - How do I get constraints on a SQL table column -
i have column called mealtype (varchar) in table check constraint {"veg", "nonveg", "vegan"}
that'll take care of insertion.
i'd display these options selection, couldn't figure out sql query find out constraints of particular column in table.
from first glance @ system tables in ms sql server, seems i'll need use ms sql's api info. hoping sql query it.
this query should show constraints on table:
select chk.definition sys.check_constraints chk inner join sys.columns col on chk.parent_object_id = col.object_id inner join sys.tables st on chk.parent_object_id = st.object_id st.name = 'tablename' , col.column_id = chk.parent_column_id can replace select statement this:
select substring(chk.definition,2,3),substring(chk.definition,9,6),substring(chk.definition,20,5)
Comments
Post a Comment