Sybase Question:
Download Questions PDF

Given a table which contains some rows with duplicate keys, how would you remove the duplicates?

Answer:

create temporary table with same table structure and then create unique index on this temporary table with option ignore_dup_row.

now insert data into temp table from the table in which duplicate records exists.

while inserting record into temp table, duplicate rows will get ingored.

Finally temp table will have unique records

Ex:
select distinct * from table_1 into temp_table_1

truncate table_1

insert into table_1

select * from temp_table_1

This is one of the ways to eliminate duplicates.

Download Sybase Interview Questions And Answers PDF

Previous QuestionNext Question
What Is Table Partitioning in Sybase?How Do I Create A Partitioned Table That Spans Multiple Devices in Sybase?