存储过程怎样传递时间参数?
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[export] @xlslj varchar(99),@sheetname varchar(99),@sj datetime
as
exec('
select*into #qq
from OPENROWSET
(''MICROSOFT.JET.OLEDB.4.0'',''Excel 5.0;HDR=YES;DATABASE='+@xlslj+''',''select*from ['+@sheetname+'$]'')
INSERT INTO zfry
(xm,sj)
select xm,'+@sj+'
from #qq
'
)
exec exportzf 'e:\abc.xls','abc','2012-7-1'
提示语法错误,如果存储过程把时间参数去掉,就能执行,该怎样传递时间参数
------解决方案--------------------
SQL code
ALTER proc [dbo].[export] @xlslj varchar(99),@sheetname varchar(99),@sj datetime
as
exec('
select*into #qq
from OPENROWSET
(''MICROSOFT.JET.OLEDB.4.0'',''Excel 5.0;HDR=YES;DATABASE='+@xlslj+''',''select*from ['+@sheetname+'$]'')
INSERT INTO zfry
(xm,sj)
select xm,'''+@sj+'''
from #qq
'
)