Hello feelow SpiceHeads!
I have been working all morning on a MERGE statement on a Server 2008 R2 Server.
The problem I have is that it fails with a very generic error which pulls up hundreds of similar error messages which aren't getting me closer to solving the issue.
I have create a merge that is going to basically insert all data from one table into another which already has records in.
The original table is called Stock and the table to be updated is called xStock.
Basically if the Primary Key already exists in xStock I just want to update fields to prevent duplication, and if the Primary Key doesn't I want to insert the whole role as a new record.
I have created the SQL as follows:Text
USE MyDbMERGE xStock WITH (HOLDLOCK) as XstUSING StockON Xst.StockCodeIndex = Stock.StockCodeIndex/* Update */WHEN MATCHED THEN...