DBA > Job Interview Questions > Sybase Interview Questions and Answers

Given a table which contains some rows with dupl

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

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

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 .

(Continued on next question...)

Other Job Interview Questions