嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
方便快捷的sql自定义函数,能迅速明了的查看表结构
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO
CREATE FUNCTION [dbo].[TableInfor](
@tablename NVARCHAR(50)
)
RETURNS TABLE
AS
RETURN
(
SELECT 字段名 = a.name,
标识 = case when columnproperty(a.id, a.name, 'IsIdentity') = 1
then '√'
else ''
end,
主键 = case when exists (select 1 from sysobjects
where xtype = 'PK'
and name in (select name
from sysindexes
where indid in (select indid
from sysindexkeys
where id = a.id and colid = a.colid)) )
then '√'
else ''
end,
类型 = b.name ,
占用字节数 = a.length ,
长度 = columnproperty(a.id, a.name, 'PRECISION') ,
允许空 = case when a.isnullable = 1
then '√'
else ''
end,
默认值 = isnull(e.text, '') ,
字段说明 = isnull(g.[value], '')
from syscolumns a
left join systypes b on a.xusertype = b.xusertype
inner join sysobjects d on a.id = d.id and d.xtype = 'U' and d.name <> 'dtproperties'
left join syscomments e on a.cdefault = e.id
left join sys.extended_properties g on a.id = g.major_id and a.colid = g.minor_id
where d.name=@tablename --需要查询的表名
--order by a.id,a.colorder
)
GO