Avatar of dejandejanovic
dejandejanovic
 asked on

OpenRowSet procedure: is not a valid identifier! Need someone to check code.

Hi,
I have problem to insert Openrowset method into procedure as getting an error "Is not invalid identifier".
Openrowset works if it is execute with normal query.

USE [TestDB]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[procTEST]

AS
DECLARE @TEST VARCHAR(MAX)
SET @TEST = 
'
Select COUNT(*) FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0'', ''Excel 12.0;Database=C:\Users\test\Desktop\test.xlsx;HDR=YES;IMEX=1'', ''SELECT * FROM [Sheet1$]'') as a
'
EXEC @test

Open in new window


Thanks in advance for help!
Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
dejandejanovic

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jasonduan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
dejandejanovic

ASKER
Crap, only brackets. It seems I was to tired yesterday :-). Thanks.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23