获取表中列的详细信息
发布时间:2020-12-12 13:40:48 所属栏目:MsSql教程 来源:网络整理
导读:create proc GetListsColumnInfoByTableName(@tablename varchar(10))as beginSELECT z.name as 列名,(case when z.is_identity = 1 then 'PK' else '' end) as 主键,x.name as 类型,max_length as 长度,(case when z.is_nullable = 0 then 'N' else 'Y' end
create proc GetListsColumnInfoByTableName(@tablename varchar(10)) as begin SELECT z.name as 列名,(case when z.is_identity = 1 then 'PK' else '' end) as 主键,x.name as 类型,max_length as 长度,(case when z.is_nullable = 0 then 'N' else 'Y' end) as 可空 from sys.systypes x inner join sys.all_columns z on x.xusertype = z.user_type_id and z.object_id = (select object_id from sys.all_objects where name = 'Customer') end exec GetListsColumnInfoByTableName 'Customer' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容