CREATE FUNCTION dbo.ISOweek (@s varchar(100)) RETURNS int AS BEGIN declare @ISOweek int select top 10 * from dbo.datable where province like @s order by iden SET @ISOweek=1 RETURN(@ISOweek) END;
有点不明白,TOP 10 什么意思,能给解释一下吗, 我做的函数: CREATE Function L_CompileAllAuthor(@id as varchar(10)) returns varchar(200) begin declare @s as varchar(8000) set @s='' select @s=@s+ltrim(rtrim('姓名:' + author_name)) + ','+ltrim(rtrim('排序:' + Convert(nvarchar(2),author_order)+';')) from ( select author_order,L_compile_author.author_name,L_compile_author.author_id from L_compile_author ,l_compile where l_compile.compile_id=L_compile_author.compile_id and L_compile_author.compile_id = @id order by author_order ) A set @s=stuff(@s,1,0,'') return @s end用author_order这个字段进行排序
CREATE FUNCTION dbo.ISOweek (@s varchar(100)) RETURNS TABLE AS RETURN (select top 10 city from dbo.datable where province like @s order by startip) select * from dbo.ISOweek ('%广州%') city -------------------------------------------------- NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
CREATE Function L_CompileAllAuthor(@id as varchar(10)) returns varchar(200) as declare @s as varchar(8000) set @s='' select @s=@s+ltrim(rtrim('姓名:' + author_name)) + ','+ltrim(rtrim('排序:' + Convert(nvarchar(2),author_order)+';')) from ( select author_order,L_compile_author.author_name,L_compile_author.author_id from L_compile_author ,l_compile where l_compile.compile_id=L_compile_author.compile_id and L_compile_author.compile_id = @id order by author_order ) A set @s=stuff(@s,1,0,'') return @s
RETURNS int
AS
BEGIN
declare @ISOweek int
select top 10 * from dbo.datable where province like @s order by iden
SET @ISOweek=1
RETURN(@ISOweek)
END;
我做的函数:
CREATE Function L_CompileAllAuthor(@id as varchar(10))
returns varchar(200)
begin
declare @s as varchar(8000)
set @s=''
select @s=@s+ltrim(rtrim('姓名:' + author_name)) +
','+ltrim(rtrim('排序:' + Convert(nvarchar(2),author_order)+';'))
from
(
select author_order,L_compile_author.author_name,L_compile_author.author_id from L_compile_author ,l_compile
where l_compile.compile_id=L_compile_author.compile_id
and L_compile_author.compile_id = @id order by author_order
)
A
set @s=stuff(@s,1,0,'')
return @s
end用author_order这个字段进行排序
RETURNS TABLE
AS
RETURN (select top 10 city from dbo.datable where province like @s order by startip)
select * from dbo.ISOweek ('%广州%')
city
--------------------------------------------------
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
returns varchar(200)
as
declare @s as varchar(8000)
set @s=''
select @s=@s+ltrim(rtrim('姓名:' + author_name)) +
','+ltrim(rtrim('排序:' + Convert(nvarchar(2),author_order)+';'))
from
(
select author_order,L_compile_author.author_name,L_compile_author.author_id from L_compile_author ,l_compile
where l_compile.compile_id=L_compile_author.compile_id
and L_compile_author.compile_id = @id order by author_order
)
A
set @s=stuff(@s,1,0,'')
return @s