Declare @Url varchar(8000) --asv文件路径
set @url='C:/Documents and Settings/Administrator/桌面'
declare @t varchar(50),@col varchar(10)
set @t='deliveries_3.csv' --asv文件名称
set @col='Yikai' --定义一个参数
--用动态的方法插入数据库中
declare @sql varchar(8000)
set @sql='insert into deliveries(Emailaddress,MailingName,deliverytime)
select Email,'''+@col+''',[Event date-time]
from OpenRowset(''MSDASQL'',''Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir='+@url+';'',''select * from '+@t+''')'
exec(@sql)