Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a query like

list all column with datatype for tables in sql server 2005

Eg:


SchemaName Tablename ColoumnName Datatype

dbo employee firstname varchar(20)
dbo employee empid int
dbo employee address varchar(max)
Posted

you can use following t-sql :

SQL
SELECT      TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,  COLUMN_NAME,DATA_TYPE, CHARACTER_MAXIMUM_LENGTH AS MAX_LENGTH
FROM        INFORMATION_SCHEMA.COLUMNS
WHERE       TABLE_NAME = 'YourTableName'
ORDER BY    TABLE_NAME, COLUMN_NAME
 
Share this answer
 
v2
Hi
I want the solution

In which both the DataType and MAXLENGTH will be in the Same Column


Table_catalog OwnerType TableName ColoumnName DataType
Northwind dbo Categories CategoryName nvarchar(15)
varchar(200)
int
Decimal(15,0)
nvarchar(60)


Same Way when we Create and Modify the table in the Enterprise manager for SQL SERVER
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900