1 select COL_LENGTH('Person.ContactType','name') 2 SELECT * FROM 3 4 /*系统函数*/ 5 --COL_LENGTH(table,column) select COL_LENGTH(Person.ContactType,name) 6 select COL_LENGTH('Person.ContactType','name') 7 8 --COL_NAME(table_id,column_id) 9 select COL_NAME(OBJECT_ID('Person.ContactType'),1) 10 select COL_NAME(OBJECT_ID('Person.ContactType'),2) 11 select COL_NAME(OBJECT_ID('Person.ContactType'),3) 12 select COL_NAME(OBJECT_ID('Person.ContactType'),4) 13 select COL_NAME(OBJECT_ID('Person.ContactType'),5) 14 select COL_NAME(OBJECT_ID('Person.ContactType'),6) 15 select COL_NAME(OBJECT_ID('Person.ContactType'),7) 16 17 --DATALENGTH(expression)函数:返回数据表达式的数据的实际长度函数 18 select DATALENGTH(name) from Person.ContactType 19 20 --DB_ID(database_name) 返回数据库的编号 21 select DB_ID('master') 数据库的编号 22 select DB_ID('tempdb') 数据库的编号 23 select DB_ID('model') 数据库的编号 24 select DB_ID('msdb') 数据库的编号 25 select DB_ID('AdventureWorks2008R2') 数据库的编号 26 27 --DB_NAME(database_id) 返回数据库的名称 28 29 SELECT DB_NAME(0) 系统默认数据库 30 SELECT DB_NAME(1) 31 SELECT DB_NAME(2) 32 SELECT DB_NAME(3) 33 SELECT DB_NAME(4) 34 SELECT DB_NAME(5) 35 SELECT DB_NAME(6) 36 SELECT DB_NAME(7) 37 SELECT DB_NAME(8) 38 SELECT DB_NAME(9) 39 SELECT DB_NAME(10) 40 SELECT DB_NAME(11) 41 SELECT DB_NAME(12) 42 43 44 SELECT USER_NAME() 45 46 --返回数据库当前默认的null值 47 48 select * from sysobjects where xtype='U' ORDER BY crdate desc 49 50 select * from sysobjects where xtype='S' ORDER BY crdate DESC 51 52 select * from sysobjects where xtype='V' ORDER BY crdate DESC 53 54 select * into #Table_1 from exec('select distinct xtype from sysobjects ') as a 55 select * from #Talbe_1 56 SELECT [name],[1],[2],[3] 57 FROM #Table_1 58 pivot 59 ( 60 sum(score) for subject_id in ([1],[2],[3]) 61 ) as pvt 62 63 64 select * from sysobjects where xtype='SP' ORDER BY crdate DESC