IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[sys_sql_addvar]') AND type = 'P')
DROP PROCEDURE [dbo].[sys_sql_addvar]
GO
-- sys_sql_addvar @varname,@datatype,@fldsize,@fldprec,@isNew output
create procedure [dbo].[sys_sql_addvar](
@varname varchar(50),
 @datatype varchar(20),
 @fldsize int,
 @fldprec int,
 @isNew int output
)as
begin
set @isNew=0
if (exists(select * from flatVarDef where varname=@varname))
return
insert into flatVarDef(varname,datatype,fldsize,fldprec) values(@varname,@datatype,@fldsize,@fldprec)
set @isNew=1

end