Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Dynamic excel path

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-09-09 : 07:54:28
Hi,

I have a sql query that reads data from excel file.
Currently the sheetname and excel path are hard-coded. How can I change them to dynamic (using parameters)?

Thanks


SELECT left (cast(convert(varchar , [division description] )as varchar (max))
,charindex(' ',cast(convert(varchar , [division description] )as varchar (max)),1)-1)
as itemcatalog_businessunit_description
INTO #tmptest

FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\test\Catalog_big.xls',
' SELECT * FROM [catalog SU08$]')
declare @pathname varchar (3000)
set @pathname='[catalog SU08$]'


Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
   

- Advertisement -