1
MERGE
을 임시 테이블에서 일반 테이블로 변환하려고합니다. 그러나 SQL Server Management Studio에서는 UPDATE
문에 ZipCodeTerritory
테이블 이름에 오류가 표시됩니다.병합 구문에 구문이 잘못됨
전에 MERGE
을 작성하지 않았지만 아래 구문에 잘못된 내용이 없습니다. Intellisense 오류보고는 Management Studio에서 잘 설명 할 수 없으므로 다른 사람이 아래 쿼리의 문제점을 볼 수 있습니까?
MERGE INTO ZipCodeTerritory as Target
USING ZipCodeTerritoryTemp as Source
ON
Target.Id = Source.Id
WHEN MATCHED THEN
UPDATE ZipCodeTerritory SET Target.ChannelCode = Source.ChannelCode, Target.DrmTerrDesc = Source.DrmTerrDesc, Target.IndDistrnId = Source.IndDistrnId,
Target.StateCode = Source.StateCode, Target.ZipCode = Source.ZipCode, Target.EndDate = Source.EndDate, Target.EffectiveDate = Source.EffectiveDate,
Target.LastUpdateId = Source.LastUpdateId, Target.LastUpdateDate = Source.LastUpdateDate, Target.ErrorCodes = Source.ErrorCodes,
Target.Status = Source.Status
WHERE Target.Id = Source.Id
WHEN NOT MATCHED THEN
INSERT INTO ZipCodeTerritory (ChannelCode, DrmTerrDesc, IndDistrnId, StateCode, ZipCode, EndDate, EffectiveDate, LastUpdateId, LastUpdateDate, ErrorCodes, Status)
VALUES(Source.ChannelCode, Source.DrmTerrDesc, Source.IndDistrnId, Source.StateCode, Source.ZipCode, Source.EndDate, Source.EffectiveDate, Source.LastUpdateId, Source.LastUpdateDate, Source.ErrorCodes, Source.Status)