据的系统对象的文档 , sysobjects.xtype
可以是这些对象类型中的一种:
| xtype | Description |
|-------|---------------------------------------|
| AF | Aggregate function (CLR) |
| C | CHECK constraint |
| D | Default or DEFAULT constraint |
| F | FOREIGN KEY constraint |
| L | Log |
| FN | Scalar function |
| FS | Assembly (CLR) scalar-function |
| FT | Assembly (CLR) table-valued function |
| IF | In-lined table-function |
| IT | Internal table |
| P | Stored procedure |
| PC | Assembly (CLR) stored-procedure |
| PK | PRIMARY KEY constraint (type is K) |
| RF | Replication filter stored procedure |
| S | System table |
| SN | Synonym |
| SQ | Service queue |
| TA | Assembly (CLR) DML trigger |
| TF | Table function |
| TR | SQL DML Trigger |
| TT | Table type |
| U | User table |
| UQ | UNIQUE constraint (type is K) |
| V | View |
| X | Extended stored procedure |
我可以把这些变成一个CASE
语句,但有一个表,我可以快快加入到该查找xtype
描述? 我知道systypes
是不是该表。 我的意思是,我只是有种记住了很多人,但我做了一些研究的数据库,它是外国对我来说(即我不知道一吨左右的话),所以我想建这说明进入该查询没有CASE
语句:
select object_name(c.id), c.name, [length], o.xtype from syscolumns c
join sysobjects o on o.id = c.id
where c.name like '%job%code%'
Update
下面是SQLMenace答案后的最终结果。 我觉得有必要在这里地方,因为它不只是一个简单的join
。
select object_name(c.id), c.name, t.name, c.[length], o.xtype, x.name from syscolumns c
join sysobjects o on o.id = c.id
join systypes t on t.xtype = c.xtype
join master..spt_values x on x.name like '%' + o.xtype + '%' and x.type = 'O9T'
where c.name like '%job%code%'
order by c.xtype