首页 > 技术文章 > T-SQL编程

llxy 2014-09-16 16:03 原文

  1. 数据类型

          数字类型 bigint,int,decimal(p,s)<p:精度,就是小数点左边和右边的位数总和,s:小数点后位数>,money,近似数字(float,real),日期类型(datatime,data),字符类型(char<固定长度>,varchar<长度不固定>,text,Unicode<字符串(可以表示国际上任何文字utf8)>,nchar,nvarchar,ntext)

  2. 变量

    变量=@+变量名

    声明语句 declare  变量 类型

  3. 给变量赋值

    declare @name varchar(20);

    set @name='test';

    select @name;

  4.打印变量

    print 变量

    select 变量

  5.运算符

     +,-,*,/,%,逻辑运算符(and,or,>,<,=,<>,!=),赋值运算符(=)  set @age=@age+1   《注意:没有++,--,+=,-=》

  6. 语句

    if(条件)

    begin

    end

    else

    begin

    end

 

    while(条件)

    begin

    end

    case:该语句具有一个返回值

  7.起别名

    as '别名'

    '别名'=字段

    字段 '别名'  (不推荐)

推荐阅读