Solved

reference to an Excel cell in an SQL Command text

Posted on 2014-04-08
7
258 Views
Last Modified: 2016-06-04
How I can reference to an Excel cell in an SQL Command text? Getting  'error converting data type varchar to uniqueidentifier'

exec sp_executesql N'SELECT CustomFieldEntryView.* FROM CustomFieldEntryView WHERE (DataResourceId = @DataResourceId)',N'@DataResourceId uniqueidentifier',@DataResourceId = Sheet1!$C$2
0
Comment
Question by:prfraczek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 43

Expert Comment

by:Eugene Z
ID: 39991141
please clarify what you try to do.


if you plan to query Excel from sql server
you can set linked server:

How to use Excel with SQL Server linked servers and distributed queries
http://support.microsoft.com/kb/306397


or use OPENROWSET
http://technet.microsoft.com/en-us/library/ms190312.aspx
 for example:
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
         'Excel 12.0;Database=c:\test.xls;HDR=YES',
         'SELECT * FROM [Sheet1!$C$2])
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39991528
Where does your command run - on sql server, in Excel VBA, or in standalone application?
0
 

Author Comment

by:prfraczek
ID: 39991538
excel Data-From other Sources- Microsoft query-SQL Command text
0
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 500 total points
ID: 39991985
In excel, you have to design the query with parameter(s).

http://office.microsoft.com/en-us/excel-help/use-microsoft-query-to-retrieve-external-data-HA010099664.aspx?CTT=1

Then, in the worksheet, you'll be able to tell that the value of the parameter should be taken from C2.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

739 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