Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
NickBloodworth
Starting Member
3 Posts |
Posted - 2010-02-19 : 10:03:54
|
Hi, I'm trying to import 600 records from a customer list in Excel into a SQL table and am having issues.In SQL server mgnt express I've created a linked server to the excel file and can run queries against it using "select * from openquery(excel, 'select * from [Sheet1$]').How can I use this to import the data? The customers table and the excel worksheet have the same columns in the same order.Thanks,Nick |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-19 : 10:08:06
|
just use likeinsert into openquery(.....)select columns... from table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
NickBloodworth
Starting Member
3 Posts |
Posted - 2010-02-19 : 10:42:35
|
I get an error when I use it. Msg 15281, Level 16, State 1, Line 1SQL 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'm using SQL express 2005 |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-19 : 10:45:43
|
quote: Originally posted by NickBloodworth I get an error when I use it. Msg 15281, Level 16, State 1, Line 1SQL 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'm using SQL express 2005
The error message is descriptive. As suggested go to Surface Area Configuration and enable Ad Hoc Distributed Queries or use sp_configure system sphttp://www.kodyaz.com/articles/enable-Ad-Hoc-Distributed-Queries.aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
NickBloodworth
Starting Member
3 Posts |
Posted - 2010-02-19 : 11:51:11
|
Now I enter ...Insert into hELLO_TELECOM.DBO.Customers Select * FROM OPENquery(excel, 'SELECT customernumber,customername,contactname,address1,address2,address3,address4,postcode,phone1,email FROM [Sheet1$]')and get an error OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "excel" returned message "No value given for one or more required parameters.".Msg 7320, Level 16, State 2, Line 1Cannot execute the query "SELECT customernumber,customername,contactname,address1,address2,address3,address4,postcode,phone1,email FROM [Sheet1$]" against OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "excel". |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-19 : 11:54:18
|
Make sure that the number of columns are same in both the tables and excelMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|