declare @result nvarchar(max)
set @result = ''
declare @param varchar(max)
declare @div varchar(1)
set @param = '1,2,4'
set @div = ','
declare @index int
declare @pos int
declare @order int
declare @temp varchar(max)
set @index = 1
set @pos = 1
while @pos > 0
begin
set @pos = charindex(@div, @param, @index)
if @pos = 0
begin
set @temp = right(@param, len(@param) - @index + 1)
end
else
begin
set @temp = substring(@param, @index, @pos-@index)
end
if len(@temp) > 0
begin
set @temp = rtrim(ltrim(@temp))
if @index = 1
begin
set @result = @result + BoardSample.dbo.test(@temp)
end
else
begin
set @result = @result + ' / ' + BoardSample.dbo.test(@temp)
end
end
set @index = @pos + 1
end
select @result
----function---------------------------
create function test(@temp char(1))
returns nvarchar(max)
as
begin
declare @return nvarchar(max)
set @return =
case @temp
when '1' then '장르1'
when '2' then '장르2'
when '3' then '장르3'
else '장르4'
end
return @return
end
댓글 영역