IF Not Exists(SELECT fieldname FROM fieldmaster WHERE fieldname = @fieldname)
insert into fieldmaster (fieldname, tooltip, label,labelalign, controltype, controlalign,
[values], defaultvalues, minlength, maxlength, [required], [validation], isactive)
values (@fieldname, @tooltip, @label, @labelalign, @controltype, @controlalign,
@values, @defaultvalues, @minlength, @maxlength, @required, @validation, @isactive)
END
BEGIN
IF Exists (select id from fieldmaster where fieldname = @fieldname)
BEGIN
Declare @ids as int = 0
select @ids = id from fieldmaster where fieldname = @fieldname
if(@id=@ids)
BEGIN
Update fieldmaster set fieldname = @fieldname, tooltip=@tooltip, label=@label, labelalign=@labelalign,
controltype= @controltype, controlalign=@controlalign, [values]= @values, defaultvalues=@defaultvalues,
minlength=@minlength, maxlength= @maxlength, [required]= @required, [validation] =@validation, isactive = @isactive where id = @id
END
END
ELSE
BEGIN
Update fieldmaster set fieldname = @fieldname, tooltip=@tooltip, label=@label, labelalign=@labelalign,
controltype= @controltype, controlalign=@controlalign, [values]= @values, defaultvalues=@defaultvalues,
minlength=@minlength, maxlength= @maxlength, [required]= @required, [validation] =@validation, isactive = @isactive where id = @id
END
END