--输出字符串"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 + 1 end create database studentInfo on 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 student go create 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) go use student go create 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 = @@rowcount go