从execl导入数据到数据库中,并且根据对应条件 2表关联更新

select * into temp2 from OPENROWSET('MICROSOFT.JET.OLEDB.4.0',

 'Excel 5.0;HDR=YES;DATABASE=d:\\a.xls',sheet1$);         

exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

UPDATE T1 SET
t1.CRMUserID_nvarchar=t2.CRMUserID_nvarchar
FROM temp T1
INNER JOIN temp2 T2 ON T1.email_nvarchar=T2.email_nvarchar

你可能感兴趣的:(从execl导入数据到数据库中,并且根据对应条件 2表关联更新)