Hello,
I am unable to resolve an error message for following user defined function.
Scope of this function:
This functions generates a unique identifier no from a table and returns it to caller.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION SystemNoShiva1
( -- Add the parameters for the function here
)
RETURNS int
AS
begin
DECLARE @st2 numeric(18,0)
DECLARE @sys01 numeric(18,0)
declare sys cursor for Select Max(SystemNo) From TISSystemMst1
open sys
Fetch sys into @sys01
begin
--DECLARE @st2 numeric(18,0)
if (@@fetch_status = 0)
-- IF @@ROWCOUNT <> 0
close sys
Deallocate sys
select @sys01 = @sys01 + 1
--update TISSystemMst1 set systemno = (@sys01)
insert into TISSystemMst1 values(@sys01)
select @st2 = @sys01
end
RETURN @st2
end
Messeg I receive is
Msg 128, Level 15, State 1, Line 17
The name "sys" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
How can I clear above error message
Nilkanth Desai