Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to find UDT on SQL Server columns?

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

Find SQL Server LOB Columns

How to List all indexes of all SQL tables

How to find SQL Filtered Indexes

Find LOB tables with no PRIMARY KEY


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

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.

Working...

Post a comment on How to find UDT on SQL Server columns?


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer