Reputation: 255
i have this function
create function getmobnum(@input bigint)
RETURNS bigint
as
begin
declare @output varchar(10)='';
declare @i int = 1;
while @i <= (len(@input)) begin
declare @unicode varchar(1) = substring(cast(@input as varchar(10)), @i, 1);
if @i>3 and @i<9
begin
set @output=@output+'*';end
else
begin
set @output=@output+@unicode;end
set @i=@i+1;
end
return @output
end;
i call function here
declare @premob varchar(10)='';
set @premob= dbo.getmobnum(@premo);
but this error Occur
Error converting data type varchar to bigint.
Upvotes: 0
Views: 32
Reputation: 166536
You function states that it will be returning a bigint, but @output which is returned is a varchar.
Change the function to also return a varchar.
Upvotes: 2