I have a simple function. It has not finished yet, but while doing intermediate check, I'm getting an error saying Invalid column name 'chksum1'
ALTER FUNCTION [dbo].[fnMidCheckSum]
(
@MID varchar(16)
)
RETURNS int
AS
BEGIN
DECLARE
@checkdiget int,
@tp int,
@chksum int,
@chksum1 int
set @checkdiget = 0
select @tp = CAST(LEFT(@MID,1) AS INT)
if ((@tp * 2) > 9)
begin
set @chksum1 = @tp * 2
set @chksum = @chksum1 / 10
set @chksum = @chksum + (chksum1 % 10)
end
RETURN @checkdiget
Cannot figure out what's wrong. Or may be my eyes just tired from the long day