2013-04-26 11 views
10

Secondo the sysobjects documentation, può essere uno di questi tipi di oggetti:Esiste una tabella che contiene l'elenco delle descrizioni 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   | 

e ho potuto mettere quelli in una dichiarazione di CASE, ma c'è un tavolo posso solo unirsi a ricerca che xtype descrizione? So che lo systypes non è quel tavolo. Voglio dire, ho appena memorizzato un sacco di loro, ma sto facendo qualche ricerca su un database ed è estraneo a me (cioè non ne so molto) e quindi mi piacerebbe costruire che la descrizione in questa query senza una dichiarazione 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%' 
Aggiornamento

di seguito è riportato il risultato finale dopo la risposta SQLMenace. Ho ritenuto necessario collocarlo qui, perché non è solo un dritto 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 

risposta

11

c'è questa

SELECT name 
FROM master..spt_values 
WHERE type = 'O9T' 

uscita

AF: aggregate function 
AP: application 
C : check cns 
D : default (maybe cns) 
EN: event notification 
F : foreign key cns 
FN: scalar function 
FS: assembly scalar function 
FT: assembly table function 
IF: inline function 
IS: inline scalar function 
IT: internal table 
L : log 
P : stored procedure 
PC : assembly stored procedure 
PK: primary key cns 
R : rule 
RF: replication filter proc 
S : system table 
SN: synonym 
SQ: queue 
TA: assembly trigger 
TF: table function 
TR: trigger 
U : user table 
UQ: unique key cns 
V : view 
X : extended stored proc 
sysobjects.type, reports 
+0

Fantastic risposta !! Ho modificato la mia domanda con il risultato finale perché il 'join' è leggermente diverso dalla norma, in modo che tutti potessero avere una chiara immagine di come mi sono unito a esso. –

Problemi correlati