Skip to content

How remove from user database type duplicate records with id 221

I have the following stored procedure:

udtSurveys is used like params by stored procedure.

Before inserting records into table surveys I need to remove all duplicate column with Id from udtSurveys.

Would you please show me an example of how use group by or another way to remove duplicated records before inserting to table?

Advertisement

Answer

You can simply use a CTE to filter all the duplicate rows from @surveys parameter.

I’ve updated your query with a cte_tbl by assuming you want to keep the original rows and remove its duplicates.

User contributions licensed under: CC BY-SA
8 People found this is helpful