How to identify all the columns with datatype

the following code shows how to identify all the columns with datatype.


SELECT OBJECT_NAME(c.OBJECT_ID) TableName, c.name ColumnName
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
WHERE t.name = 'nVarchar' --you can change 'nVarchar' to other datatypes
ORDER BY c.OBJECT_ID;
GO


Comments

Author: Kapil Dhawan18 Jun 2008 Member Level: Gold   Points : 2

Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code will help lots of guys
Thanks to you
Regards,
Kapil

Author: ketha11 Jun 2009 Member Level: Silver   Points : 0

select TABLE_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: