我想使用 bulkCopy 存储过程,然后使用合并 upsert。
这是我的存储过程
@bulkLdapGroup [TEMP_LDAP_GROUP] readonly
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
merge into [SECURITY_CUBE].[dbo].[LDAP_GROUP] as Target
using @bulkLdapGroup as Source
on Target.[GROUP_NAME]=Source.[GROUP_NAME]
when matched then
update set Target.[DESCRIPTION]=Source.[DESCRIPTION], Target.[WHEN_CREATED] = Source.[WHEN_CREATED],Target.[UPDATED_DATE]= GetDate()
when not matched then
insert ([GROUP_NAME],[DESCRIPTION],[WHEN_CREATED],[UPDATED_DATE]) values (Source.[GROUP_NAME],Source.[DESCRIPTION],Source.[WHEN_CREATED],GetDate());
end
如何使用 bulkCopy 传递表并执行此存储过程?在 c# 代码中,我想将 Datatable 作为参数传递,然后执行这个存储过程。