Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Scripts          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 

INFORMATION_SCHEMA.COLUMN_DOMAIN_USAGE



By:

Overview
The INFORMATION_SCHEMA.COLUMN_DOMAIN_USAGE view allows you to get information about alias data types that are used for columns By default it will show you this information for every single table and view that is in the database that uses an alias data type.

Explanation
This view can be called from any of the databases in an instance of SQL Server and will return the results for the data within that particular database.

The columns that this view returns are as follows:

Column name Data type Description
DOMAIN_CATALOG nvarchar(128) Database in which the alias data type exists.
DOMAIN_SCHEMA nvarchar(128) Name of schema that contains the alias data type.
DOMAIN_NAME sysname Alias data type.
TABLE_CATALOG nvarchar(128) Table qualifier.
TABLE_SCHEMA nvarchar(128) Table owner.
TABLE_NAME sysname Table in which the alias data type is used.
COLUMN_NAME sysname Column using the alias data type.

(Source: SQL Server 2005 Books Online)


Here is an example of data that was pulled from the AdventureWorks database.  This data was pulled using this query:

SELECT * FROM INFORMATION_SCHEMA.COLUMN_DOMAIN_USAGE

In the results below we can see that the data type "Name" in the DOMAIN_NAME column is used in several tables for columns ReviewerName (ProductReview) and Name (AddressType, ProductSubcategory, UnitMeasure).


To see the underlying data types for these aliased data types you can use this query.

SELECT DISTINCT DOMAIN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
DOMAIN_NAME IS NOT
NULL

Last Update: 7/2/2009




More SQL Server Solutions











Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools