September 26, 2009

List All Tables and Views with the XML Data Type in SQL Server 2005/2008

Here’s a simple way of listing all tables and Views with the XML datatype using the INFORMATION_SCHEMA views.

SELECT DISTINCT col.TABLE_NAME, col.COLUMN_NAME, col.DATA_TYPE  
FROM INFORMATION_SCHEMA.COLUMNS as col
WHERE col.DATA_TYPE = 'xml'

As given in the Books Online “Information schema views provide an internal, system table-independent view of the SQL Server metadata. Information schema views enable applications to work correctly although significant changes have been made to the underlying system tables. The information schema views included in SQL Server comply with the ISO standard definition for the INFORMATION_SCHEMA.”

OUTPUT

image


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

No comments: