--用T-SQL得到数据库表的默认值select 默认值名称=a.name,
默认值=b.text,
所属表名=object_name(d.id),
所属列名=d.name
from sysobjects a join syscomments b on a.id=b.id
join sysconstraints c on c.constid=a.id
join syscolumns d on c.colid=d.colid and c.id=d.id
where a.xtype='D' and object_name(d.id)<>'dtproperties'
默认值=b.text,
所属表名=object_name(d.id),
所属列名=d.name
from sysobjects a join syscomments b on a.id=b.id
join sysconstraints c on c.constid=a.id
join syscolumns d on c.colid=d.colid and c.id=d.id
where a.xtype='D' and object_name(d.id)<>'dtproperties'
解决方案 »
- 请问sql server中有类似Oracle to_char的按一定格式输出的函数吗?
- sql 关键字 in
- 2008打开脚本乱码
- 求SQL,table1去重插入table2
- sql语句查询除去前n项的记录出错,大家看看怎么回事?
- sql 字符比较
- 跪求sql算法(在线等,急)
- 如何使用sql语句将sybase数据库中的数据导入ms sql server
- 怎么用SQL返回相同字段的第一条记录
- 请问:Sql server2000 企业版能否在windows xp 上安装,windows 2003是否也支持????
- 一个数据字段里面共存简,日,韩三种语言的数据(十万火鸡,再线等)
- 请问高手这个数据库语句应该怎么写
select case when c.colid=1 then object_name(c.id) else '' end as 表名
,c.name as 字段名
,t.name 数据类型
,c.prec as 长度
,p.value as 字段说明
,m.text as 默认值
from syscolumns c
inner join systypes t on c.xusertype=t.xusertype
left join sysproperties p on c.id=p.id and c.colid = p.smallid
left join syscomments m on c.cdefault=m.id
where objectproperty(c.id,'IsUserTable')=1
Applies ToSQLServer2 Object
Syntaxobject.EnumCollations( ) as QueryResultsPartsobjectExpression that evaluates to an object in the Applies To listPrototype (C/C++)HRESULT EnumCollations(LPSQLDMOQUERYRESULTS *ppResults);ReturnsA QueryResults object that contains one result set defined by these columns.Column Data type Description
Name String Collation name
Description String Collation description
ResEnumCollations is similar to the ListCollations method, and is used in conjunction with column-level collation. After using EnumCollations to enumerate the collation names, an application can set the Collation property to use a specific collation with a Database2 or UserDefinedFunction object.Note牋營f an application calls EnumCollations on an instance of SQL Server version 7.0, the constant, SQLDMO_E_SQL80ONLY, and the message "This property or method requires Microsoft SQL Server 2000" are returned.See AlsoCollation Property
ListCollations Method
where a.id=object_id('表') and a.name='字段'