September 9, 2009 at 9:01 am
Hi,
How can i change the path and sheetname to parameters with the correct syntax?
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;DATABASE=c:\test\Catalog_big.xls;IMEX=1', 'Select * from [catalog SU08$]')
Thanks
September 9, 2009 at 11:43 pm
Not real familiar with openrowset, but ordinarily in a situation like this I'd sugest dynamic sql to solve this issue.
Something like:
declare @sql varchar(500),
@path varchar(50),
@sheet varchar(50)
set @path = 'C:\test\'
set @sheet = 'Catalog_big.xls'
set @sql =
'SELECT * FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
''Excel 8.0;DATABASE=' + @path + @sheet+ ';IMEX=1'', ''Select * from [catalog SU08$]'')'
EXEC(@SQL)
I'm freehanding this so I may have screwed up a quote or 10, but that's the general idea.
September 9, 2009 at 11:43 pm
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply