Use SQL Server to import data in Excel to Oracle

Source: Internet
Author: User

This article provides an indirectExcelData Import inOracleMethod: UseSQL ServerClose relationships with Excel. in SQL Server, use the OpenDataSource method to read Excel and spell the data into an oracle-compliant SQL statement.

Run the following code in SQL server:

 
 
  1. SELECT 'Update userinfo set Useducation = '''
  2.  
  3. + Case when [current educational level] is nullthen''
  4.  
  5. ELSE [current education level] END
  6.  
  7. + CASEWHEN [technical level] is nullthen''
  8.  
  9. ELSE ''', Usskilllevel = ''' + [technical level] END + ''''
  10.  
  11. + CASEWHEN [Joining Parties] is nullthen''
  12.  
  13. ELSE ', Usdangtuantime = to_date (''' + CONVERT (VARCHAR (12), [Joining Parties], 110) + ''', ''mm-dd-yyyy '') 'end
  14.  
  15. + CASEWHEN [inbound working date] is nullthen''
  16.  
  17. ELSE ', Usinputtime = to_date (''' + CONVERT (VARCHAR (12), [inbound working date], 110) + ''', ''mm-dd-yyyy '') 'end
  18.  
  19. + CASEWHEN [Date of Birth] is nullthen''
  20.  
  21. ELSE ', Usbirthdate = to_date (''' + CONVERT (VARCHAR (12), [Date of Birth], 110) + ''', ''mm-dd-yyyy '') 'End
  22.  
  23. + 'Where Uscardid = ''' + [ID card number] + ''';'
  24.  
  25. From opendatasource ('Microsoft. Jet. OLEDB.4.0 ',
  26.  
  27. 'Data Source = D: \ gongren.xls; Extended Properties = Excel 8.0 ')... [Sheet1 $]

Note:

1) provide the correct file path and Sheet name;

2) Close the Excel file to be read; otherwise, an error is reported;

3) Make sure that the field corresponding to the to_date function is of the date type in Excel;

The execution result is as follows:

 
 
  1. Update userinfo set Useducation = 'medium specialization', Usinputtime = to_date ('12-25-2000 ', 'Mm-dd-yyyy'), Usbirthdate = to_date ('09-06-1976 ', 'Mm-dd-yyyy') where Uscardid = '000000 ';
  2.  
  3. Update userinfo set Useducation = '', Usskilllevel = 'intermediate work', Usdangtuantime = to_date ('07-11-2000', 'Mm-dd-yyyy '), usinputtime = to_date ('07-01-2003 ', 'Mm-dd-yyyy'), Usbirthdate = to_date ('08-21-1979 ', 'Mm-dd-yyyy ') where Uscardid = '20140901 ';
  4.  
  5. Update userinfo set Useducation = '', Usskilllevel = 'Senior employee', Usdangtuantime = to_date ('07-03-2001 ', 'Mm-dd-yyyy '), usinputtime = to_date ('01-01-2005 ', 'Mm-dd-yyyy'), Usbirthdate = to_date ('10-26-1980 ', 'Mm-dd-yyyy ') where Uscardid = '20140901 ';

Execute the above Code in pl/SQL.

This article introduces,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.