本文介绍了合并声明问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我遇到的Merge语句有一个问题,以下是我的merge语句,它的插入和更新语法运行良好,但删除不起作用.有人可以建议我需要修改的内容吗?
Hi All,
I am facing a issue with Merge statement below is my merge statement and its insert and update syntax is running fine but delete is not working. Can anybody suggest me what need to modify
string Sql_Statement = @" MERGE INTO Organization With (ROWLOCK) AS Target " +
" USING (VALUES " + valuesCommunities.Substring(0, valuesCommunities.Length - 1) + " ) " +
" AS Source (LegacyOrganizationID, CustomerID, OrganizationName, Address1, Address2, City, [State], CountryID, Zip, Phone, Fax, DateAdded, AddedBy, DateModified, ModifiedBy, DateDeleted, DeletedBy, IsActive, ReferenceID) " +
" ON Target.legacyOrganizationId=Source.legacyOrganizationID " +
" AND Target.CustomerId=Source.CustomerID " +
" WHEN MATCHED THEN " +
" UPDATE SET LegacyOrganizationID = Source.LegacyOrganizationID, CustomerID = Source.CustomerID, OrganizationName = Source.OrganizationName, Address1 = Source.Address1, Address2 = Source.Address2, City = Source.City, State = Source.State, CountryID = Source.CountryID, Zip = Source.Zip, Phone = Source.Phone, Fax = Source.Fax, DateModified = Source.DateModified, ModifiedBy = Source.ModifiedBy, DateDeleted = Source.DateDeleted, DeletedBy = Source.DeletedBy, IsActive = Source.IsActive" +
" WHEN NOT MATCHED BY TARGET THEN " +
" INSERT (LegacyOrganizationID, CustomerID, OrganizationName, Address1, Address2, City, [State], CountryID, Zip, Phone, Fax, DateAdded, AddedBy, DateModified, ModifiedBy, DateDeleted, DeletedBy, IsActive) " +
" VALUES (Source.LegacyOrganizationID, Source.CustomerID, Source.OrganizationName, Source.Address1, Source.Address2, Source.City, Source.[State], Source.CountryID, Source.Zip, Source.Phone, Source.Fax, Source.DateAdded, Source.AddedBy, Source.DateModified, Source.ModifiedBy, Source.DateDeleted, Source.DeletedBy, Source.IsActive) " +
" WHEN NOT MATCHED BY Source THEN Delete" +
" OUTPUT $action, Inserted.OrganizationID, Inserted.LegacyOrganizationID,Source.ReferenceID; ";
等待您的建议
谢谢
AP
Waiting for your kind sugggestion
Thanks
AP
推荐答案
等待您的建议
谢谢
AP
Waiting for your kind sugggestion
Thanks
AP
这篇关于合并声明问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!