Home > Mobile >  How can I skip the first few rows of a xlsx source in the OpenRowset if the sheet name has a space i
How can I skip the first few rows of a xlsx source in the OpenRowset if the sheet name has a space i

Time:10-29

I have a .xlsx file that I am trying to import into SSIS in Visual Studio 2019. I need to skip the first 3 rows and start at row 4, which contains the header. My usual approach to this is to modify the OpenRowset under custom properties of the excel source to include the range I want. The problem is that this automatically-generated excel file has a space in the sheet name, and nothing I do seems to work.

If I remove the space, and enter the following:

Sheet1$A4:K

There are no issues. Unfortunately, because there is a space, none of the following seem to work:

'Sheet 1$A4:K'
"Sheet 1$A4:K"
'Sheet 1'$A4:K
'Sheet 1$'A4:K
Sheet 1$A4:K
'Sheet 1$'$A4:K

I'm running out of ideas here, and I cannot believe how much trouble I am having finding a solution online. What is the proper syntax/what do I need to do to get this to work?

CodePudding user response:

Wrap the entire name and range in brackets ([]). For example:

SELECT *
FROM [Sheet 1$A4:K]
  • Related