0

please help SSIS

I have the following as sql query when using an excel connection

August being the tab name

select * from [August$A14:N14]

But i want it to open on a specific month only for example tab August (the tab name will change per month when i run the package hence trying to use the variable)

and rows A14:N14

i have tried something like the following

declare @monthname as varchar(20)=  DATENAME(month,DATEADD(MONTH, 
DATEDIFF(MONTH, 0, GETDATE())+2, 0))    

select * from [@monthname$A14:N14]

but I cannot get it to work

any suggestions please

update: i have tried variable method below too - i get invalid bracketing error

select * from [@(User::vMonth)$A14:N14]

please help

Nick.Mc
  • 18,304
  • 6
  • 61
  • 91
Joeysonic
  • 255
  • 3
  • 11
  • 1
    Your sql statement needs to be an _expression_ https://www.sqlshack.com/ssis-expression-task-vs-evaluating-variable-as-expression/ – Nick.Mc May 24 '22 at 11:16
  • select * from [@[User::vMonth]$A14:N14] i get error invalid bracketing...i did try [@(User::vMonth)$A14:N14] same error please help @nick.mcdermaid – Joeysonic May 24 '22 at 11:39
  • Read and understand expressions. https://learn.microsoft.com/en-us/sql/integration-services/expressions/integration-services-ssis-expressions?view=sql-server-ver16 you need to set your sheet name as an "expression" then you can put text in there that is evaluated. – Nick.Mc May 24 '22 at 11:54
  • Perhaps this will help. I haven't used SSIS for many years so it's hard to guide you step by step https://stackoverflow.com/questions/42563777/dynamic-excel-sheets-load-into-sql-using-ssis – Nick.Mc May 24 '22 at 11:55

0 Answers0