Which query will give the table structure with column definitions in SQL?
A:
This depends on your database vendor. Mostly it's the "information schema" you should Google for (applies to MySQL, MSSQL and perhaps others).
dark_charlie
2010-07-29 12:05:50
A:
select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='<Table Name>'
You can get details like column datatype and size by this query
Pankaj Upadhyay
2010-07-29 12:05:51
A:
Sql server
DECLARE @tableName nvarchar(100)
SET @tableName = N'members' -- change with table name
SELECT
[column].*,
COLUMNPROPERTY(object_id([column].[TABLE_NAME]), [column].[COLUMN_NAME], 'IsIdentity') AS [identity]
FROM
INFORMATION_SCHEMA.COLUMNS [column]
WHERE
[column].[Table_Name] = @tableName
Gaby
2010-07-29 12:12:17