Sql Server编程
1.注釋語句
?????????單行 --
?????????多行? /*??????????????????? */
2.申明變量
?????????declare @lastname? nvarchar(30),@firstname? nvarchar(20)
3賦值
?????????select @mycounter=20
?????????set @myvar1='this is a test'
???????? set @rows=(select count(*) from authors)
4 if??? else
??????????if (select avg(price) from titler where type="business")<$20
??????????????? begin
????????????????end
??????????else
?????????????? begin
?????????????? end
????????? if? [not] exists (select 語句)?????????????????????? --只要檢測到一條記錄就返回正確結果
????????????????句組1
??????????else
??????????????? 句組2
5while
?????????while not exists(select price from titles where price<$30)
???????????????begin
????????????????????????update titles
????????????????????????set price=price*1.5
????????????????????????select max(price) from titles
????????????????????????if(select?max(price) from titles)>$50
?????????????????????????????????break;
????????????????????????else
?????????????????????????????????continue;
???????????????end
6 case
??????select? "作者"=
??????????????????case? state
????????????????????????when? "ca"? then? "來自加利福尼亞州"
????????????????????????when "ks"???then? "來自印度"
????????????????????????else?? "來自其他州"
????????????????? end
??????from authors? order by state
7? transaction
?????????begin? tran??? [tranname]
?????????commit? [tran]? [tranname]
?????????rollback? [tran]? [tranname]
?????????seve tran? [savepointname]
?????? for example:
??????????? begin? transaction? exampletrans
????????????save? tansaction???percentchanged
????????????rollback?transaction percentchanged
????????????commit??tansaction
????????????
?????????
轉載于:https://www.cnblogs.com/wuyong/archive/2006/10/17/531129.html
總結
以上是生活随笔為你收集整理的Sql Server编程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: timestamp 数据类型
- 下一篇: System Memory Manage