Let's say I have a table named Sample with the following columns:
ID - int identity(1,1)
Col1 - varchar(10)
Col2 - varchar(10)
Col3 - varchar(10)
Col4 - varchar(10)
Let's say the data in this table are as follows:
I would like to remove duplicates from this table having the same Col1 and Col2 values but I would prefer to delete those rows where Col3 or Col4 or both Col3 and Col4 are null. So in the above example, I would prefer to delete the rows with ID = 1, 3, 4, and 6, and keep the rows with ID = 2 and 5.
How do I do this? Please show your transact SQL code solution.
Thanks in advance!