SQL Server SQL data column merge together if value exists already

bxfogqkk  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(102)

SQL Server screenshot

SQL

SELECT [Order Number]
      ,[Date]
      ,[Name]
      ,[Email]
      ,[Return ID]
      ,[Createddateandtime]
      ,[Item Quantity]
FROM [PowerBIXPO].[dbo].[ReturnHeader]

I have just started using SQL I need to merge both columns together if the value already exists. I am using SSIS to import return customer data to a SQL Server table which works fine but because the source CSV file contains the data on a separate column and is inserting the data on a new line instead of merging the data together but unable to do this.

If the column Return ID and Item Quantity already exist, it needs to merge the data and total the quantities can you somebody provide a solution to this please.

I am using SSIS integration services to merge the data before inserting it into the SQL Server table.

inb24sb2

inb24sb21#

Have you considered NOT polluting your data by importing it into the final table, but to import it into a staging table and then process it from there - then you can remove duplicates in this table. Using staging tables is standard data loading practice since - not sure. 30 years at least. You can then remove duplicates and do a classical MERGE statement that can be used to either insert or update.

相关问题