首页 > 其他 > 详细

系统函数

时间:2017-04-18 21:23:04      阅读:207      评论:0      收藏:0      [点我收藏+]
 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

 

系统函数

原文:http://www.cnblogs.com/ailanglang/p/6730474.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!