:::: MENU ::::

Column names and datatypes in a table

dbDigger, Monitoring and Analysis, System Stored Procedures, T-SQL Scripts

Column names and datatypes in a table

I was required to generate a list of column names along with their data types in a table. For information about a table i used sp_help.

 
USE DBNameHere  
 GO  
 sp_help tableName  
 GO  

And for more to the point result with any filtration required i used following script

Use DBNameHere
GO
SELECT Table_Schema,Table_Name,Column_Name,Data_Type
FROM information_schema.columns
WHERE table_name = ‘TableNameHere’
GO

This produced exact that i wanted.

Consult us to explore the Databases. Contact us