views:

25

answers:

1

hi, i have a set of excel data containing merge cells that needs to be imported into sql server. However, the results of import show null for cells that are merged.

i have tried using IMEX function, testing with values 0,1,2. but it still imports merge cells as null. is there a way to this? thank you

SELECT * INTO BenchmarkSurvey FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=C:\Benchmark Survey\Received\Survey1009.xls; Extended Properties="Excel 8.0;IMEX=1"')...[Sheet1$];
A: 

See this. Moreover, you can also try to export the excel file to a CSV file and then import it to SQL Server

Edit: this link may be of use: merged cells behavior

Hal
seems like your is helpful for reporting.but i wish to import data into SQL Server.
marilyn
OK, try exporting the table to .csv and importing it to SQL Server then. You can do it programatically (http://stackoverflow.com/questions/425379/how-to-export-data-as-csv-format-from-sql-server-using-sqlcmd) or you can use the GUI (http://msdn.microsoft.com/en-us/library/ms140052.aspx)
Hal
or is it feasible to use rownumber(), and update cells with previous row data if it is null?
marilyn
If you know what to put in null rows, sure.
Hal
I have imported a set of data from excel with merge cells into sql server.in the sql table, it now contains:period | product ID | price | qty2006 | 123 | 100 | 1null | null | null | 2null | null | null | 22007 | 321 | 20 | 1null | null | null | 2null | null | null | 2null | null | null | 2i wish to populate null values based on the previous row record.I attempted to assign row number, but can't do an 'over' syntax, being afraid it might change the order of raw data.So how do i go abt this?
marilyn
First of all, create a duplicate of that table to avoid losing data.
Hal
Secondly, i think you'll need to use a loop to run through all the records in the table and then use a query resembling this:
Hal
http://support.microsoft.com/kb/111401
Hal