/*student location 表.属性分别用S L开头*/create function get_All
(@name char(10))
returns table as
return
select
Sno,Sname,Ssex,Sclass,Sbirth,Sqq,LpreName as'SProvince',Lname as'Scity',Sphoto,Sscore
from student,location
where Sname like @name+'%' and Scity=Lno/*执行函数*/
select get_All.Sno,get_All.Sname,get_All.Ssex,get_All.Sclass,get_All.Sbirth,get_All.Sqq,get_All.SProvince,get_All.Scity,get_All.Sphoto,get_All.Sscore
from get_All('张')
/*没有结果*/
/*直接查询*/
Sno,Sname,Ssex,Sclass,Sbirth,Sqq,LpreName as'SProvince',Lname as'Scity',Sphoto,Sscore
from student,location
where Sname like '张'+'%' and Scity=Lno
/*直接查询有结果*/
google上找不到相关调试信息,各位来指点一二啊
(@name char(10))
returns table as
return
select
Sno,Sname,Ssex,Sclass,Sbirth,Sqq,LpreName as'SProvince',Lname as'Scity',Sphoto,Sscore
from student,location
where Sname like @name+'%' and Scity=Lno/*执行函数*/
select get_All.Sno,get_All.Sname,get_All.Ssex,get_All.Sclass,get_All.Sbirth,get_All.Sqq,get_All.SProvince,get_All.Scity,get_All.Sphoto,get_All.Sscore
from get_All('张')
/*没有结果*/
/*直接查询*/
Sno,Sname,Ssex,Sclass,Sbirth,Sqq,LpreName as'SProvince',Lname as'Scity',Sphoto,Sscore
from student,location
where Sname like '张'+'%' and Scity=Lno
/*直接查询有结果*/
google上找不到相关调试信息,各位来指点一二啊
(@name nvarchar(10)) ---修改下类型
returns table as
return
select
Sno,Sname,Ssex,Sclass,Sbirth,Sqq,LpreName as'SProvince',Lname as'Scity',Sphoto,Sscore
from student,location
where Sname like @name+'%' and Scity=Lno
go
/*执行函数*/
select get_All.Sno,get_All.Sname,get_All.Ssex,get_All.Sclass,get_All.Sbirth,get_All.Sqq,get_All.SProvince,get_All.Scity,get_All.Sphoto,get_All.Sscore
from get_All(N'张')
nchar(10)
是定长数据类型
declare @s nchar(10)
set @s='張'
select @s+'三'
select len(@s+'三')
/*
------------
張 三(1 個資料列受到影響)
-----------
11(1 個資料列受到影響)*/