How to insert data from Excel sheet to SQL Server 2005

前端 未结 2 655
日久生厌
日久生厌 2021-01-25 23:12

I have an Excel sheet now I need to insert data from that sheet into SQL Server 2005.

I need to create a temp table and insert data into that table. The database name i

相关标签:
2条回答
  • 2021-01-25 23:45
    --Excel 2007-2010
    
    
    INSERT INTO DATABASE.SCHEMA.TABLENAME
    SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Excel 12.0 Xml;HDR=YES;Database=C:\SheetName.xlsx','SELECT * FROM [SheetName$]');
    
    --Excel 97-2003
    
    
    INSERT INTO DATABASE.SCHEMA.TABLENAME
    SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.4.0',
    'Excel 8.0;HDR=YES;Database=C:\SheetName.xls','SELECT * FROM [SheetName$]');
    
    0 讨论(0)
  • 2021-01-25 23:46

    A simple search: http://support.microsoft.com/kb/321686

    Probably easiest is

    SELECT *
    INTO #tmptable
    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'Excel 8.0;Database=C:\test\xltest.xls', [SheetName$])
    
    0 讨论(0)
提交回复
热议问题