zoukankan      html  css  js  c++  java
  • SQL Server 2012

    1. 变量
       --全局变量
       select @@VERSION 
       
       --局部变量
       declare @i int
       set @i=5
       select @i  
    2. 通配符:   like   'joh%',  %任意长度的任意字符 ;   like 'joh_'  -单个字符 ;  like '[jk]ohn'  [jk] 匹配字符集合中的一个字符   ;  like '[^jh]' [^jh] 不包含j和h开头的
    3. 数据库权限控制语句(DDL)
        --权限控制
      
        --赋予权限
        grant update,delete,select on Course
        To [guest]  with grant option
      
        -- 拒绝更新
        deny update on Course
        To [guest] cascade
      
        -- 收回权限操作
        revoke delete on Course
        To [guest] cascade
    4. 流程控制语句
      1. while
          --流程控制
          declare @Count int
          set @Count=0
        
        	while(@Count<10)
        		begin 
        			print @Count
        			set @Count=@Count+1
        		end 
      2. if else
          declare @Age int
          set @Age=20
        	if(@Age<30)
        		print 'Young'
        	else
        		print 'Old'
      3. Case When
      4. Goto 语句
      5. Waitfor Delay 延迟执行 
           declare @Name varchar(10)
           set @Name='Micky'
        	 begin
        		waitfor delay '00:00:05'
        		print @Name
        	 end
      6. Return语句:终止当前T-SQL语句的执行,或者返回结果

             --创建 表值函数方法
        	 use SchoolDB
        	 Go
        	 create function FunGetStuByID(@stuID varchar(10))
        	 returns Table
        	 as 
        		return 
        		(
        			select * from Student where StuID=@stuID
        		)
        	 -- 调用方法
             select * from FunGetStuByID('003')
  • 相关阅读:
    wmq的A×B Problem
    MATLAB 求系统的单位冲击响应及单位阶跃响应
    关于共享率过低的一些事
    Vue组件之间的通信
    浏览器支持ES6的import和export
    Vue axios拦截问题
    开屏倒计时
    git常用操作
    原型
    this指向问题
  • 原文地址:https://www.cnblogs.com/i-shanghai/p/6289879.html
Copyright © 2011-2022 走看看