Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)归海一刀published in(发表于) 2014/2/1 0:23:32 获取所有用户表及根据表Id取得表字段信息_[SQL,Server教程]
sql_pub = "select id, [name], crdate from sysobjects d where d.xtype = 'U' and d.name <> 'dtproperties' order by a.[name] asc"
sql_pub = " SELECT " & _ " a.[name] as '字段名称'" & _ " , (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) as 标识" & _ " , b.name 类型" & _ " , a.length 占用字节数" & _ " , (case when a.isnullable = 1 then '√'else '' end) 允许空" & _ " , isnull(e.text,'') 默认值" & _ " , cast(isnull(g.[value],'') as varchar(100)) AS 字段说明" & _ " FROM syscolumns a" & _ " left join systypes b" & _ " on a.xtype = b.xusertype" & _ " left join syscomments e" & _ " on a.cdefault=e.id" & _ " left join sysproperties g" & _ " on a.id = g.id AND a.colid = g.smallid" & _ " where a.id = " & table_id & _ " order by a.colorder"
赞