从多个Excel中导入数据入库

注意的一点时加个newid字段,以记录使每一次导入都不同,可恢复之类的操作


DECLARE @nid varchar(50)
DECLARE @dt  datetime


SET @nid = newid()
SET @dt = getdate()

INSERT INTO CustomerTemp


SELECT   'zhuyunbo' AS Developer, 销售部门 AS DepartmentName, 日期 AS ReceiveDate,
工号 AS WorkNo, 顾问姓名 AS SalesStaffName, 客户姓名 AS CustomerName, 地址 AS Address,
联系电话 AS Tel, 性别 AS Sex, 身高体重年龄 AS Height_Weight_Age,
客户状态 AS CustomerStatus, 沟通记录  AS Record1,
F12  AS Record2,
NULL AS Record3,
@dt AS ImportDate,
@nid As nd
FROM   OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source= "G:\发展部数据资料\发展部祝云波资料.xls";Extended Properties= "Excel 5.0;HDR=YES;Excel 8.0";Persist Security Info=False ')...[客户资料库$]

print @nid

print @dt