Copy rows from one table to another, ignoring duplicates

前端 未结 9 1384
半阙折子戏
半阙折子戏 2020-11-27 13:44

I have 2 tables (srcTable1 & destTable) that have identical schemas. I am trying to copy all rows from srcTable to destTable and ignore the duplicates. I thought I could

9条回答
  •  庸人自扰
    2020-11-27 14:33

    DISTINCT is the keyword you're looking for.

    In MSSQL, copying unique rows from a table to another can be done like this:

    SELECT DISTINCT column_name
    INTO newTable
    FROM srcTable
    

    The column_name is the column you're searching the unique values from.

    Tested and works.

提交回复
热议问题