aruba
Programmer
- Sep 5, 2003
- 47
I am trying to create a function that changes the first 2 numbers to 'A' when the number reaches 1,000,000. The source is a numeric datatype so I need to convert it as well. Here is my code, which works as long as it's not a function. Any help would be greatly appreciated!
create function wkctl.parentwo_convertToP3(@parentwo bigint)
returns varchar
as
begin
declare @char_parentwo varchar
if @parentwo between 999999 and 1099999
select replace(@parentwo,substring(convert(varchar(15),@parentwo),1,2),'A')
set @char_parentwo = @parentwo
return (@char_parentwo)
end
create function wkctl.parentwo_convertToP3(@parentwo bigint)
returns varchar
as
begin
declare @char_parentwo varchar
if @parentwo between 999999 and 1099999
select replace(@parentwo,substring(convert(varchar(15),@parentwo),1,2),'A')
set @char_parentwo = @parentwo
return (@char_parentwo)
end