10
據the sysobjects documentation,可以是下列對象類型中的一種:是否有一張表包含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%'
更新
下面是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
意想不到的答案!我用最終結果編輯了我的問題,因爲'join'與標準有點不同,所以每個人都可以清楚地瞭解我是如何加入的。 – 2013-04-26 19:42:44