openrowset

openrowset for excel: can we skip several rows?

心已入冬 提交于 2019-11-29 09:36:36
I will use the following sql to read data from excel, but sometimes I need to skip first several rows. e.g the real data begins from line 5, so I need to skip the first 4 rows, is that doable? SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls', 'SELECT * FROM [sheet1$]'); Use a range [sheet1$A5:Z] instead of the entire sheet [sheet1$] SELECT * FROM OPENROWSET( 'Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls', 'SELECT * FROM [sheet1$A5:Z]' ); This will number the rows being obtained, with no specific order (as luck

How to resolve “Could not find installable ISAM.” error for OLE DB provider “Microsoft.ACE.OLEDB.12.0”

扶醉桌前 提交于 2019-11-29 09:11:39
I am trying to import data from Excel 2007 (.xlsx) files into SQL Server 2008 using a T-SQL OpenRowset() command with the "Microsoft.ACE.OLEDB.12.0" OLE DB provider, and I'm getting a persistent "Could not find installable ISAM" error. All hardware is 32-bit. [Revised 1/10/12 to try to focus more sharply on the anomalies] The following T-SQL statement produces the error: SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES"', 'SELECT * FROM [Sheet1$]' ) If I save the Excel file in the "Excel 97-2003" format (.xls)

Trying to Import FoxPro DBF File to SQL Server

女生的网名这么多〃 提交于 2019-11-29 08:47:35
As the title says, I'm trying to import a FoxPro dbf file into sql server using openrowset. At first I tried to export the DBF to an xls file and import using the Import/Export wizard. This works pretty well normally, but there is one field that sometimes holds a really long string, and this string is being truncated at 4096 characters during the export from the dbf to xls. I found an old post with instructions on how to do this using openrowset. When I try the first answer: select * from openrowset('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver; SourceDB=\\path\; SourceType=DBF', 'select *

error executing OPENROWSET (BULK) / Azure SQL Database

最后都变了- 提交于 2019-11-28 10:54:50
问题 I am logged into an Azure SQL Database, using "Active Directory - Integrated" authentication wherein I supply my company domain credentials only; no password. I tried executing OPENROWSET on a .json file stored on my client (laptop): Select BulkColumn from OPENROWSET (BULK 'C:\Users\username\Downloads\docs_by_day_IncludeDocs.json', SINGLE_CLOB) as my_test which returned: Msg 4861, Level 16, State 1, Line 12 Cannot bulk load because the file "C:\Users\username\Downloads \docs_by_day

Cannot initialize the data source object of OLE DB provider “MSDASQL” for linked server “(null)”

偶尔善良 提交于 2019-11-28 06:35:32
Having an interesting issue. I'm reading from an excel file on a server via an OpenRowset in Sql2005. I've run the query a number of times without any problems. I've just gone out for a quick meeting and suddenly I get the error "Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)"" I've made sure the files are not in use on the server and even deleted them and recopied them over onto the server and still I'm getting the same error. UPDATE: This only seems to happen if I join two selects from different openrowsets. If I run the queries individually

How to resolve “Could not find installable ISAM.” error for OLE DB provider “Microsoft.ACE.OLEDB.12.0”

喜欢而已 提交于 2019-11-28 02:35:04
问题 I am trying to import data from Excel 2007 (.xlsx) files into SQL Server 2008 using a T-SQL OpenRowset() command with the "Microsoft.ACE.OLEDB.12.0" OLE DB provider, and I'm getting a persistent "Could not find installable ISAM" error. All hardware is 32-bit. [Revised 1/10/12 to try to focus more sharply on the anomalies] The following T-SQL statement produces the error: SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML

Trying to Import FoxPro DBF File to SQL Server

佐手、 提交于 2019-11-28 02:06:50
问题 As the title says, I'm trying to import a FoxPro dbf file into sql server using openrowset. At first I tried to export the DBF to an xls file and import using the Import/Export wizard. This works pretty well normally, but there is one field that sometimes holds a really long string, and this string is being truncated at 4096 characters during the export from the dbf to xls. I found an old post with instructions on how to do this using openrowset. When I try the first answer: select * from

The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”

点点圈 提交于 2019-11-27 19:21:01
I'm trying to run the following statement but am receiving the error messages just below. I have researched answers to no end and none have worked for me. I'm running Office 365 (64bit). I have loaded the Microsoft Access Database Engine (64bit). This is in Visual Studio 2013 with SSDT as well as SQL Server 2012. I do not have access to changing environment or startup parameters to SQL Server. Any help is appreciated. SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.15.0', 'Excel 12.0;Database=C:\Users\UserName\Folder\SomeFile.xlsx;;HDR=NO;IMEX=1', [Table 1$]) Msg 7399, Level 16, State 1, Line 1

SQL Server export to Excel with OPENROWSET

这一生的挚爱 提交于 2019-11-27 15:19:21
I am successfully exporting to excel with the following statement: insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\template.xls;', 'SELECT * FROM [SheetName$]') select * from myTable Is there any standard way to use this template specifying a new name for the excel sheet so that the template never gets written to or do I have to come up with some work-around? What's the best way to do this in people experience? gbn You'd have to use dynamic SQL. OPENROWSET etc only allows literals as parameters. DECLARE @myfile varchar(800) SET @myfile = 'C:\template.xls' EXEC ('

How to create and populate a table in a single step as part of a CSV import operation?

喜夏-厌秋 提交于 2019-11-27 13:15:21
I am looking for a quick-and-dirty way to import CSV files into SQL Server without having to create the table beforehand and define its columns . Each imported CSV would be imported into its own table. We are not concerned about data-type inferencing. The CSV vary in structure and layout, and all of them have many many columns, yet we are only concerned with a few of them: street addresses and zipcodes. We just want to get the CSV data into the SQL database quickly and extract the relevant columns. I'd like to supply the FieldTerminator and RowTerminator, point it at the CSV, and have the