Context: I have several files in a folder, so I do not want to put the path one by one, so I need to add my command variables.
Set @nome_arquivo = '252203408.xlsx'
Set @sql='SELECT *
FROM OPENROWSET(
''Microsoft.ACE.OLEDB.12.0'',
''Excel 12.0 Xml;Database=\00.000.00.000\Arquivos Power BI\TI\Arquivos Base Excel\Rateio\' + @nome_arquivo + ';HDR=YES;'',
''SELECT * FROM [Rateio$]'')'
--Cursor para percorrer os registros
DECLARE cursor_telefonia CURSOR LOCAL SCROLL FOR
Exec(@sql)
It can execute the query, but when placed inside the cursor does not work and I need this inside the cursor to be able to take all the fields and then work on the other checks. How to make the cursor read this?