wuyong

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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
            
         


posted on 2006-10-17 10:47  吴勇  阅读(242)  评论(0编辑  收藏  举报