Solved

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

Posted on 2013-12-02
2
414 Views
Last Modified: 2013-12-02
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!
0
Comment
Question by:dejandejanovic
2 Comments
 
LVL 11

Accepted Solution

by:
jasonduan earned 500 total points
ID: 39690799
Change line #16 to:

EXEC (@test)

Open in new window

0
 

Author Closing Comment

by:dejandejanovic
ID: 39691780
Crap, only brackets. It seems I was to tired yesterday :-). Thanks.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question