I need Syntax help to use BCP to load a bunch if INSERT STMTS in a file....

  • Please see pic

    Can someone help me with the syntax on using BCP.

    Here is my Requirements: I have a file that has a bunch of INSERT STATEMENTS. So the stuff inside the file looks like the following:

    File has about 5000 rows.

    INSERT INTO abc ( name ) VALUES ( 'Peter' );

    INSERT INTO abc ( name ) VALUES ( 'Bob' );

  • bcp cannot help. bcp bulk loads data...it cannot execute each row as if it were a command.

    open the file in SSMS and execute it instead. you might need to insert some GO statements every 1000 rows or so, just to make it bite sized so SSMS can handle it.

    the syntax for opening a file and executing it via sqlcmd would work, but still, i'd recommend gui tools for just 5000 rows.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I think this is what you are looking for...

    http://databases.about.com/od/sqlserver/a/bcp.htm

    I use to upload files using bcp bat files. It will insert all rows for you.

    MCSE SQL Server 2012\2014\2016

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

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