zoukankan      html  css  js  c++  java
  • sql-定义变量

    declare @subject nvarchar(50)
    
    set @subject=(select Subject from dbo.Scores where ID=1)
    

      

    --select @subject=Subject from dbo.Scores where ID=1
    --标量 标量就是单值 ,set后如果是一个结果集,则set的最终值为结果集中最后一个值
    select @subject
     
    设置自增
     
    insert into dbo.Student values ('王五','男',40);select @@IDENTITY;
       insert into dbo.Student output inserted.ID values ('李六','男',41)
    

      

     
    执行一些特定的脚本,需要考虑判断循环等行为,因此有if while等结构
    if(){}------------>sqlserver中就是 if() begin end
     
        declare @name nvarchar(50)='王五'
      if(@name='王五')
      begin
        select 'true'
      end
      else
      begin
      select 'false'
      end
     
    

      

     
    循环
      --计算1-100的和
      declare @int int=1;
      declare @total int=0;
      while(@int<=100)
      begin
      set @total=@total+@int;
      set @int=@int +1;
      end
      select @total
    

      

     
     
     
     
  • 相关阅读:
    nm applet disable
    profile和bash
    gre tunnel
    Redux
    react 组件架构
    Flux reference
    Controller View 模式
    Flux
    react事件代理
    虚拟dom和diff算法
  • 原文地址:https://www.cnblogs.com/mongo/p/4434827.html
Copyright © 2011-2022 走看看