Duplication on SonarQube analysis of SQL files

We are currently running SonarQube Server 2025.1.1 LTA whereas an application team scan their SQL scripts. A piece of code in a lengthy sql file is given below. While analyzing the sql file, since there are insert and exec commands were repeated several times, SonarQube flagged them as duplicate. How to get this duplication issue resolved?

declare @dfid int 
exec datafileDel '2669',1 
insert into datafiles (firmid,filetype,delimiter) values (2669,1,null) 
set @dfid = SCOPE_IDENTITY() 
insert into process_datafiles ( pruniqueid, dfuniqueid ) 
select prid, @dfid 
from @t 
declare @clid2021 int 
insert into columnlocation (colstart, colend, colorder, dfuniqueid, colname) values (11,18,11,@dfid,'cusip') 
set @clid2021 = SCOPE_IDENTITY() 
insert into columnformat (dcuniqueid,cluniqueid,formatid,formatorder,param) values (null,@clid2021,506,19,null) 
declare @clid2022 int 
insert into columnlocation (colstart, colend, colorder, dfuniqueid, colname) values (181,212,23,@dfid,'ticker') 
set @clid2022 = SCOPE_IDENTITY() 

Appreciate your help in advance!

Hey there.

If refactoring isn’t possible (and I’m not enough of SQL expert to say if it is), you can always exclude the file from duplication detection.

Hello @Colin

Thank you for your response.

I came to know about https://docs.sonarsource.com/sonarqube-server/2025.1/project-administration/analysis-scope#duplication-exclusions from support to exclude files from duplication detection. This method would not prevent this file from being scanned. Issues, code smells, security hotspots, etc would still be reported on this file. It would only exclude that file from duplication checking.

Thanks.