17 May,2023 by Tom Collins
Question: I want to find SQL Server table columns which are using user-defined types . I also want to find SQL Server columns in which the nulability at the column level is different from the nullability set at the user-defined type level.
Answer: These are some queries you can use to find the UDT information. One thing to be aware of is that one of the purposes of UDT is to offer strong typing structure beyond the standard SQL Server types used on columns
Query 1 : Find table name , column referening user-defined types
select object_name(object_id) as table_name,sc.name from sys.columns sc inner join sys.types st ON sc.user_type_id = st.user_type_id where st.is_user_defined = 1
Query 2 : Find table name , columns where the nullability at the column level is different to the nullability at the UDT level
select object_name(object_id) as table_name,sc.name from sys.columns sc inner join sys.types st ON sc.user_type_id = st.user_type_id where st.is_user_defined = 1 and sc.is_nullable <> st.is_nullable
Read more on finding other SQL Server objects
List Foreign Keys referencing tables in SQL Server
What are the triggers in SQL Server
How to find all identity columns in SQL Server
How to find default values of all SQL Server columns
How to find computed columns on a SQL Server table
How to List all indexes of all SQL tables
How to find SQL Filtered Indexes
Find LOB tables with no PRIMARY KEY
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |