Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-12-02
2
Medium Priority
?
458 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

972 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