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!
dejandejanovicAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jasonduanConnect With a Mentor Commented:
Change line #16 to:

EXEC (@test)

Open in new window

0
 
dejandejanovicAuthor Commented:
Crap, only brackets. It seems I was to tired yesterday :-). Thanks.
0
All Courses

From novice to tech pro — start learning today.