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.
| Author |
Topic |
|
zubinbalsara
Starting Member
2 Posts |
Posted - 2007-01-30 : 12:13:38
|
| HI Guys,Is there a way to use a variable worksheet name in the openrowset. I need to open an excel file in my cursor, my worsheet name is not constant all the time,so i need to place a variable instead. Here is a snippet from my codedeclare @mysheet varchar(200)set @mysheet='sheet1$'Declare getDistrict cursor forSELECT district, healthplan FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;HDR=Yes; IMEX=1;Database=D:\DatabaseUploads\Nexium\crestor.xls', 'SELECT * FROM ['''+@mysheet+''']') WHERE [District] IS NOT NULL set nocount on;open getDistrictThanks for all your help |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|