SQLServer技术(15)

来源:互联网 发布:免费恢复数据软件 编辑:程序博客网 时间:2024/06/08 13:14
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

4.5.1注释符(Annotation)
在Transact-SQL中可使用两类注释符。
ANSI标准的注释符“--”用于单行注释;
与C语言相同的程序注释符号,即“/**/”。“/*”用于注释文字的开头,“*/”用于注释文字的结尾,可在程序中标识多行文字为注释。

4.5.2运算符(Operator)
    1算术运算符
包括:+(加)、―(减)、(乘)、(除)、%(取余)
    2比较运算符
包括:>(大于)<(小于)、=(等于)、>=(大于等于)、<=(小于等于)、<>
(不等于)、!=(不等于)、!>(不大于)!<(不小于)
其中!=、!>、!<不是ANSI标准的运算符。
    3逻辑运算符
包括:AND(与)、OR(或)、NOT(非)
    4位运算符
包括:按位与、|(按位或)、~(按位非)^(按位异或)
    5连接运算符
连接运算符“+”用于连接两个或两个以上的字符或二进制串、列名或者串和列的混合体,将一个串加入到另一个串的末尾。其语法如下:
+
例4-7
usepangu
declare@startdatedatetime
set@startdate=‘1/1/2000’
select‘StartDate:’+convert(varchar(12)@startdate)
--convert()函数用于转换数据类型,见4.8.4
运行结果如下:
StartDate:Jan12000
例4-8:
usepangu
select‘月薪最高的员工是:‘+e_name+’月薪为:‘+convert(varchar(10)e_wage
fromemployee
wheree_wage=
(selectmax(e_wage)
fromemployee)
运行结果如下:
月薪最高的员工是:张三月薪为8000.00
(1row(s)affected)
在Transact-SQL中运算符的处理顺序如下所示,如果相同层次的运算出现在一起时则处理顺序位从左到右。

括号()位运算符~算术运算符*、/、%算术运算符+、-位运算符^位运算符&位运算符|逻辑运算符NOT/逻辑运算符AND逻辑运算符OR

4.5.3通配符Wildcard
在中可以使用如表4-4所示的通配符。

表4-4Transact-SQL的通配符


<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>