ibcadmin 发表于 2013-4-19 08:41:56

查询表结构的SQL语句

用来查询表结构。

declare @table_name as varchar(max)
set @table_name = '表名'
select sys.columns.name,
sys.types.name, sys.columns.max_length,sys.columns.is_nullable,
(select count(*) from sys.identity_columns
wheresys.identity_columns.object_id = sys.columns.object_id andsys.columns.column_id = sys.identity_columns.column_id) as is_identity ,
(select value from sys.extended_properties
wheresys.extended_properties.major_id = sys.columns.object_id andsys.extended_properties.minor_id = sys.columns.column_id) as description
from sys.columns, sys.tables, sys.types where sys.columns.object_id
=sys.tables.object_id and
sys.columns.system_type_id=sys.types.system_type_id
and sys.tables.name=@table_name order by sys.columns.column_id


chao2332601 发表于 2013-6-16 01:15:20

谢谢分享!!!

chao2332601 发表于 2013-6-16 05:08:08

谢谢分享!!!

草甘膦好 发表于 2013-7-22 23:44:56

回复一下吧











static/image/common/sigline.gif
http://shop103534827.taobao.com
页: [1]
查看完整版本: 查询表结构的SQL语句