How to import Data From Excel Sheet into SQL Database using stored Procedure

  • Hi all,

    I have excel sheet and it contain Name Field and ID field. in my database contain table Personal. it has Name and ID fields. now i need to import data from that excel sheet and insert that all data into Personal table in my database.Please tel me how i do this using my stored procedure.

    Thanks,

    Harsha

  • INSERT Personal (Name, ID) SELECT Name, ID

    FROM OPENROWSET('MSDASQL',

    'Driver={Microsoft Excel-Treiber (*.xls)};

    DBQ=<filename>;HDR=NO',

    'SELECT * FROM [Tabelle1$]')

    Exchange <filename> with the filename

    if the excel-sheet contains header lines set HDR=YES,

    [Tabelle1$] is the name of the excel-sheet.

    regards

    karl

    Best regards
    karl

  • hi frnd., is that possible to import the excel sheet data through the data transformation services i.e., by running through the import/export wizard....

    Thanks,

    praveen.

  • Praveen -

    You can use the DTS tool, just change the "Data Source" to Microsoft Excel, path to your spreadsheet location and make sure you note the check box regarding first row as column names (if existing table and you are merely importing data, remove the check mark).

    Good luck

    Chris Powell

    George: You're kidding.
    Elroy: Nope.
    George: Then lie to me and say you're kidding.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply