zoukankan      html  css  js  c++  java
  • SQL SERVER 相关

    while循环

    declare @sum int;
    declare @i int;
    set @sum=0;
    set @i=0;
    while(@i<=100)
    begin
      if(@i%2!=0)
      begin
      set @sum=@sum+@i;
      end  
    set @i=@i+1;
    end
    select @sum;

    事务

    USE [shopdb]
    GO
    /****** Object:  Table [dbo].[test]    Script Date: 08/15/2018 15:29:01 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[test](
        [cid] [int] IDENTITY(1,1) NOT NULL,
        [balance] [int] NULL,
     CONSTRAINT [PK_test] PRIMARY KEY CLUSTERED 
    (
        [cid] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    USE [shopdb]
    GO
    ALTER TABLE [dbo].[test]  WITH CHECK ADD  CONSTRAINT [CK_test] CHECK  (([balance]>(10)))
    begin transaction
    declare @sumError int;
    set @sumError =0;
    update test set balance=balance-100 where cid=2;
    set @sumError = @sumError+@@error;
    update test set balance=balance+100 where cid=3;
    set @sumError=@sumError+@@error;
    
    if(@sumError<>0)
    begin
      rollback transaction
    end
    else
    begin
      commit transaction
    end
  • 相关阅读:
    Cookies
    一个完整的upstart脚本分析
    squid总结
    python递归读取目录列表
    python删除文件
    ubuntu切割mp3文件
    TP-LINK TL-WN725N V2 / rtl8188eu Linux驱动安装
    ubuntu启动脚本
    su对环境变量做了什么
    sudoers文件配置
  • 原文地址:https://www.cnblogs.com/youguess/p/9481716.html
Copyright © 2011-2022 走看看