Hi @kkran,
Not sure if you want to combine the code like below.
declare @count int select @count = (SELECT sum(CASE WHEN CHARINDEX('.',[Month1],0) > 0 THEN 1 WHEN CHARINDEX('.',[Month3],0) > 0 THEN 1 WHEN CHARINDEX('.',[Month2],0) > 0 THEN 1 WHEN CHARINDEX('.',[Month4],0) > 0
THEN 1 ELSE 0 END) FROM stagingtable )
declare @count2 int select @count2=(select count(*) from (SELECT Part_Number, Org_Name
FROM stagingtable
GROUP BY Part_Number, Org_Name
HAVING count(*)> 1) t)
if @count >0 or @count2>0
begin raiserror('There is decimal or duplicate in my_table',16,1) end
else begin INSERT INTO yourtable SELECT * FROM stagingtable end
As you said, pass in a variable for the 'Qty' column and see if value is >1 then do not process and if <1 then check the decimals and move to next steps, it is also a good way.
Regards,
Zoe Hui
If the answer is helpful, please click "Accept Answer" and upvote it.