Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Merge Statement doesn't work?

$
0
0

MERGEINTOProduction.ConstCustASTGT

USINGProduction.ConstCustUpdatesASSRC

ONTGT.CustomerId=SRC.CustomerID

USELab;

WHENMatchedTHEN

UPDATE

SETTGT.CustomerID=SRC.CustomerID,

TGT.CustomerCode=SRC.CustomerCode,

TGT.CustomerName=SRC.CustomerName,

TGT.CustomerAddress=SRC.CustomerAddress,

TGT.CustomerCity=SRC.CustomerCity,

TGT.CustomerState=SRC.CustomerState,

TGT.CustomerZipCode=SRC.CustomerZipCode,

TGT.CreditLimit=SRC.CreditLimit

WHENNOTMATCHEDTHEN

INSERT(CustomerCode,CustomerName,

CustomerAddress,CustomerCity,CustomerState,CustomerZipCode,CreditLimit)

Values(2,'Changed','Changed Name','Changed Address','Changed City','ID','83501',1000),

(4,'New','New Name','New Address','New City','CA','99999',9999);

Regards,

GGGGGNNNNN

 

 

 

 


GGGGGNNNNN


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>