Want to create an SQL function that removes table row duplicates
That's a big first step for a self-identified newbie. If I read your question correctly, you're looking to create reusable code that will delete duplicates from an arbitrary table. I'm not going to show you how to do that because it's a) dangerous and b) non-trivial. But here's how I'd do it for one table:

with cte as (
   select row_number() over (partition by col_a, col_b order by col_a) as [rn]
   from tbl
)
delete cte
where [rn] &lt;&gt; 1


This code assumes that you have a table called tbl and you're using *col_a* and *col_b* together to determine uniqueness. What's going on here is that you're essentially enumerating all of the rows within a given set that would be considered duplicate and deleting all but the first.