SQL基础2

来源:互联网 发布:俄罗斯共青城现状 知乎 编辑:程序博客网 时间:2024/05/01 16:42
--输出字符串"I love you "对应的ASCII值和字符declare @pos smallint, --位置        @string varchar(10) --字符串set @pos = 1;set @string = 'I love you'--datalength是一个全局数据,返回数据的长度while (@pos <= datalength(@string))begin     select ascii(substring(@string, @pos, 1)) as AsciiCode,   --获取ASCII码           char(ascii(substring(@string, @pos, 1))) as ascchar--获取对应的字符    set @pos = @pos + 1endcreate database studentInfoon primary( name = stu_data,  filename = 'd:\stu_data.mdf',  size = 3,  maxsize = 15,  filegrowth = 1)log on(  name = stu_log,  filename = 'd:\stu_log.ldf',  size = 1,  maxsize = 12,  filegrowth = 10%)use studentgocreate proc tea_pro(@no char(6), @name nvarchar(8), @sex nchar(1), @age int, @title nchar(5), @tel varchar(12), @salary decimal(7), @num char(10))as insert into teacher_info values(@no, @name, @sex, @age, @title, @tel, @salary, @num)gouse studentgocreate proc stud_proc    (@startdate datetime, @enddate datetime, @recordcount int output) --用output指定为返回值as    if (@startdate is null or @enddate is null)    begin        raiserror('Null value are invalid!', 5, 5)        return    end    select * from stud_info    where birthday between @startdate and @enddate    select @recordcount = @@rowcountgo


 

原创粉丝点击