prfraczek
asked on
reference to an Excel cell in an SQL Command text
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'@DataR esourceId uniqueidentifier',@DataRes ourceId = Sheet1!$C$2
exec sp_executesql N'SELECT CustomFieldEntryView.* FROM CustomFieldEntryView WHERE (DataResourceId = @DataResourceId)',N'@DataR
Where does your command run - on sql server, in Excel VBA, or in standalone application?
ASKER
excel Data-From other Sources- Microsoft query-SQL Command text
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
'Excel 12.0;Database=c:\test.xls;
'SELECT * FROM [Sheet1!$C$2])