sql-serverexcelcopy-paste

Paste MS Excel data to SQL Server


I have a bunch of rows in Excel that I want to paste into a new table in MS SQL. Is there a simple way ?


Solution

  • I have used this technique successfully in the past:

    Using Excel to generate Inserts for SQL Server

    (...) Skip a column (or use it for notes) and then type something like the following formula in it:

    ="insert into tblyourtablename (yourkeyID_pk, intmine, strval) values ("&A4&", "&B4&", N'"&C4&"')"

    Now you’ve got your insert statement for a table with your primary key (PK), an integer and a unicode string. (...)