Solved

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

Posted on 2013-12-02
2
399 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now