Share via

Importing into sql server management studio

Pamela Whittaker 1 Reputation point
Jan 26, 2021, 4:09 PM

I can see hw to create a files of sql commands from a database table but how do import it into another test database please. Do I use import flat file as taht appears to be for csv files. Thanks

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,075 questions
{count} votes

8 answers

Sort by: Newest
  1. Pamela Whittaker 1 Reputation point
    Jan 27, 2021, 9:33 AM

    Ok I am a bit nearer. I have managed to use use query options and set the delimiter to comma then run a query setting it to store to a csv file. That doesn't quite work though. It is fine unless you have a comma as part of a field entry. O dear. It isn't the whole data we want to copy - just data from a couple of tables. I understand the Bulk insert from a csv file. I hadn't come across that before. Thanks


  2. AmeliaGu-MSFT 13,991 Reputation points Microsoft Vendor
    Jan 27, 2021, 6:08 AM

    Hi @Pamela Whittaker ,

    how do import it into another test database?

    Did you mean you want to import the data to another database? You can right-click on your database and select Tasks -> Generate Scripts...
    In Set Scripting Options page, you can specify how scripts should be saved. And you can select the Types of data to script to be Data only in Advanced button.

    60824-01.jpg

    If you have to perform large imports of data from a csv file, you can use BULK INSERT statement as YitzhakKhabinsky mentioned. Or you also can use SQL Server Import and Export wizard by choosing Flat File Source as Data Source with file name. Please refer to Bulk Import and Export of Data and this simple example of the Import and Export Wizard which might help..
    If you have any other question, please feel free to let us know.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Pamela Whittaker 1 Reputation point
    Jan 26, 2021, 8:45 PM

    What if you have a large file of

    insert into .....
    insert into .....
    insert into .....
    insert into .....
    insert into .....

    The on;y thing I can think of is create new query then copy and paste


  4. Tom Phillips 17,741 Reputation points
    Jan 26, 2021, 7:58 PM
    0 comments No comments

  5. Pamela Whittaker 1 Reputation point
    Jan 26, 2021, 5:21 PM

    Bult inserts won't work will it on a file of insert statements?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.