日期:2014-05-17 浏览次数:20563 次
ALTER PROCEDURE [dbo].[Import]
@FilePath NVARCHAR(200), --eg:'D:\\DATAExchange\\CSVTMP'
@FileName NVARCHAR(100) --eg:'ExportFileOne.csv'
AS
BEGIN
DECLARE @ImpSQLstr NVARCHAR(600)
SET @ImpSQLstr='INSERT INTO TempTable (DataDate,Dataopen,DataHigh,DataLow,DataClose,DataVolume,DataOpenInt)
SELECT * FROM OPENROWSET(''MSDASQL'', '' Driver={Microsoft Text Driver (*.txt; *.csv)};
DEFAULTDIR='+@FilePath+'; Extensions=CSV;'',''SELECT * FROM "'+@FileName+'" '')'
Exec (@ImpSQLstr)
SELECT @@ROWCOUNT
END