export/import script

Posted on 2014-08-04
Last Modified: 2014-08-06
I need to import an excel sheet data (filename.xls) into a sql server db table. I have imported the sheet data into db table named filename#. Now I need to import data in filename# table into table myDestTable (which has an identity PK column.) Due to some column data type differences between the two tables, I have to write a tsql script using
Insert into ...
select ...

Are there any importing scripts samples, especially taking care of data type differences and indetity column, and etc. ?

Question by:minglelinch
    LVL 14

    Accepted Solution


    Fried there is nothing which can help you except you.

    Since the source and destination table must have same data type or you need to cast / Convert according to the destination table datatype.

    That is the simplest you can do.

    Just check the data type of destination table and convert source data to match up with it
    LVL 1

    Author Closing Comment

    Thanks for the post.
    LVL 12

    Expert Comment

    by:Harish Varghese
    You may use import wizard in SQL server management studio to take care of data type conversions automatically (wherever possible).
    LVL 1

    Author Comment

    I did it this way but failed on conversion.
    LVL 12

    Expert Comment

    by:Harish Varghese
    SSIS is the way then. You can have explicit type conversions.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now