May 18, 2009 at 12:00 pm
Hi All,
I wrote this code and hope that I can transfer the data of one column field name in Excel to another column field name of SQL 2005 (of course, the column field name in SQL must be matched with column field name of Excel file).
Insert into ROCAPData
Select SocialSecurityNumber
FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','DataSource=P:\TranAssignments\ROCAPData\ROCAP.xls;Extended Properties="Excel 8.0;IMEX=1" ')...Sheet1$
it gives me a syntax error:
"Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online."
Then I search for the hints of why I got the error message, I found one answer and that answer is to:
Go to Start Menu, Point to all program, Microsoft SQL Server 2005, Configuration Tools, and then Click SQL Server Surface Area Configuration. Click on Surface Area Configuration for Features, Then Turn on the check box Displayed : "Enable OPENROWSET and OPENDATASOURCE support" , Click OK.
After done the check box as it stated above, I run my query again but It still gives me the same error :
Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
I restarted the computer and re-run my query, but it still gives the same syntax error.
Does anyone know why I could not transfer the data of one column of Excel file to SQL Database? Please look at my code or else to tell me what wrong with my codes or alternative way to solve this issue.
Thanks
May 18, 2009 at 12:22 pm
josephptran2002 (5/18/2009)
Hi All,it gives me a syntax error:
"Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
see if this helps you out:
execute sp_configure 'show advanced options', 1
reconfigure
execute sp_configure 'ad hoc distributed queries', 1
reconfigure
execute sp_configure 'show advanced options', 1
reconfigure
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 18, 2009 at 12:23 pm
May 18, 2009 at 12:35 pm
Hi There,
Thanks, I did it and run the same codes that you suggested me to do
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
it still gives me the same error.
Thanks
May 18, 2009 at 12:35 pm
Hi There,
Can you show your way?
Thanks
May 18, 2009 at 12:39 pm
I tried to copy your codes and run it, somehow it works...but it gives me a small error. Do you know why?
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Could not find installable ISAM.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
Thanks
May 18, 2009 at 12:50 pm
May 18, 2009 at 1:44 pm
josephptran2002 (5/18/2009)
I tried to copy your codes and run it, somehow it works...but it gives me a small error. Do you know why?OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Could not find installable ISAM.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
Thanks
Is your server 64-bit? There are no 64-bit drivers for JET:(
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 18, 2009 at 2:13 pm
Hi There,
the server that I use is 32 bits
May 18, 2009 at 2:14 pm
So What command should I use?
May 18, 2009 at 2:37 pm
josephptran2002 (5/18/2009)
Hi There,Thanks, I did it and run the same codes that you suggested me to do
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
it still gives me the same error.
Thanks
You don't want to do OLE... You need to set the Ad-hoc query.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 19, 2009 at 6:23 am
Hi Wayne,
How do you set adhoc query?
Thanks
May 19, 2009 at 6:48 am
Check if the following query works for you.
SELECT *
FROM OPENROWSET
(
'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;IMEX=1;Database=P:\TranAssignments\ROCAPData\ROCAP.xls',
'SELECT * FROM [Sheet1$]'
)
--Ramesh
May 19, 2009 at 6:52 am
Hello Ramesh,
Thanks for the comments
May 19, 2009 at 7:05 am
josephptran2002 (5/19/2009)
Hello Ramesh,Thanks for the comments
Is the solution working for you?
--Ramesh
Viewing 15 posts - 1 through 15 (of 49 total)
You must be logged in to reply to this topic. Login to reply