Hi I am beginner to sqlserver and facinf a problem with functions can I get some help on it.
Here is my programm
create function fun_split
(
@string varchar(20)
)
RETURN char(5)
begin
declare @b int,@c char(5)
set @string = replace('m1,m2,m3',',','.')
set @b=0
while(@b<4)
begin
@c=parsename(@string,@b)
set @b=@b+1
return (@c)
end
end
The error am facing
Msg 156, Level 15, State 1, Procedure fun_split, Line 9
Incorrect syntax near the keyword 'RETURN'.
Msg 178, Level 15, State 1, Procedure fun_split, Line 9
A RETURN statement with a return value cannot be used in this context.
Msg 102, Level 15, State 1, Procedure fun_split, Line 16
Incorrect syntax near '@c'.
Msg 178, Level 15, State 1, Procedure fun_split, Line 18
A RETURN statement with a return value cannot be used in this context.
Here is my programm
create function fun_split
(
@string varchar(20)
)
RETURN char(5)
begin
declare @b int,@c char(5)
set @string = replace('m1,m2,m3',',','.')
set @b=0
while(@b<4)
begin
@c=parsename(@string,@b)
set @b=@b+1
return (@c)
end
end
The error am facing
Msg 156, Level 15, State 1, Procedure fun_split, Line 9
Incorrect syntax near the keyword 'RETURN'.
Msg 178, Level 15, State 1, Procedure fun_split, Line 9
A RETURN statement with a return value cannot be used in this context.
Msg 102, Level 15, State 1, Procedure fun_split, Line 16
Incorrect syntax near '@c'.
Msg 178, Level 15, State 1, Procedure fun_split, Line 18
A RETURN statement with a return value cannot be used in this context.