Hi, what is the exact logic of the following SP code. I want to translate this logic in Select statement to know the following logic and know the reason of the error which is
'Code field is not unique'. Thanks
/ cannot insert code in "CodeSection" if "code" is not unique /
DECLARE @Codenum VARCHAR(256)
declare @acount int
SELECT @Codenum=',111222222,111222233,'
select @acount=count(*) from CodeSection t2
where [Codenum] is not NULL
AND ISNULL(@Codenum, '') NOT LIKE '%,' + ISNULL([code], '') + ',%'
if @acount > 1
raiserror('Code field is not unique', 16, 10)
return