更新时间:2022-11-03 08:17:54
)' 结束
)' end
您没有发布确切的错误,但在查询中却出现了错误,我猜您的文件名中没有撇号.
另外,如果我没记错的话,openrowset命令应连接到字符串,然后在使用变量的情况下执行.
因此,请尝试使用以下内容:
You didn''t post the exact error you''re getting but bsaed on your query, I''d guess that you don''t have apostrophes in your filename.
Also if I recall correctly the openrowset command should be concatenated to a string and then executed if you use variables.
So, have a try with something like:
...
declare sqltext varxhar(1000);
...
set sqltext = 'select * into General_holydays_details from OPENROWSET(''Microsoft.jet.OLEDB.4.0'',''Excel 8.0;DATABASE='''+@filname+ '''Select Date,Day,Reason from [sheet1
)'中选择日期,日期,原因; 打印(sqltext) 执行(sqltext) ...
)'; print (sqltext) execute (sqltext) ...