Friday, July 6, 2012

Getting table structure of all tables from Database in sqlserver 2000/2005

Getting table structure of all tables from database in sqlserver 2005:


SELECT o.name AS TableName,
   c.name AS ColumnName,
   t.name AS DataType,
   c.Max_Length

FROM sysobjects AS o
INNER JOIN syscolumns AS c ON o.object_id = c.object_id
INNER JOIN systypes AS t ON c.user_type_id = t.user_type_id
WHERE type = 'U' ORDER BY TableName


Getting table structure of all tables from  database in  sqlserver 2000:



select table_name,column_name,data_type,character_maximum_length from information_schema.columns
where table_name IN ('AUDIT_WARRANT_PAYMENT_COSTBOOKING',
'AUDIT_WARRANT_PAYMENT_COSTBREAKUP',
'AUDIT_WARRANT_PAYMENTS',
'Brands'')
order by table_name