How to exclude duplicate records
Here is simple query which shows simple technique to exclude duplicate records from output. In my example I am selecting only first record from duplicate list based on Primary key. Select * into #tmp1 From( select 1 as id,'aaa' as …