函数 输出表
第一个函数
alter function [dbo].[m_split](@c text,@split varchar(2))
returns @t table(col varchar(100))
as
begin
while(charindex(@split,cast(@c as varchar(max))) <>0)
begin
insert @t(col) values (substring(cast(@c as varchar(max)),1,charindex(@split,cast(@c as varchar(max)))-1))
set @c = stuff(cast(@c as varchar(max)),1,charindex(@split,cast(@c as varchar(max))),'')
end
return
end
第二个函数
create function [dbo].[Question_split](@P varchar(50))
returns ......这里怎么写
as
begin
with maco as(
select * from [dbo].[m_split]('简历,面试,跳槽,工作机会,礼仪,' , ',')
)
select * from Question a ,maco b
where charindex(b.col,a.QuestionClassification)>0
end
return
end
第二个函数中
with maco as(
select * from [dbo].[m_split]('简历,面试,跳槽,工作机会,礼仪,' , ',')
)
select * from Question a ,maco b where charindex(b.col,a.QuestionClassification)>0
不用函数写法查出的是一张表
我的意思是怎么定义一个函数[dbo].[Question_split]
内的内容是
with maco as(
select * from [dbo].[m_split]('简历,面试,跳槽,工作机会,礼仪,' , ',')
)
select * from Question a ,maco b where charindex(b.col,a.QuestionClassification)>0
然后将查出的表
插入到一个表中
return出来
[解决办法]
DECLARE @STR NVARCHAR(200)SET @STR=',简历,面试,跳槽,工作机会,礼仪,'SELECT * FROM Question AS A WHERE @STR LIKE '%,'+QuestionClassification+',%'
[解决办法]
自己解决,还贴结果
表扬!