Script table and data

  • Hi,

    I have a table with data.

    I want to create the table and its data on other place. What is the quick way of doing this script?

    Thank you

  • I strongly recommend that you don't script the data. The file sizes get very large and Management Studio often can't handle the large files.

    Script the table (right click table -> script or right click database -> Tasks -> generate script), then use bcp out to generate a file with the data in it.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thank you for the feedback. This table has only 233 records. can I use any script function to script the data?

  • You can use the Generate Scripts to script data, but do be careful about the number of rows. There's a lot of overhead in a script of the data because of all the INSERT INTO ... statements

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (5/25/2015)


    You can use the Generate Scripts to script data

    I can not see the option to script the data. I just see the option to script the object and it's dependencies.

  • GilaMonster (5/25/2015)


    right click database -> Tasks -> generate script)

    There's an 'advanced' button on the 'Set Scripting Options' tab. In that, select to script schema and data

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • river1 (5/25/2015)


    Hi,

    I have a table with data.

    I want to create the table and its data on other place. What is the quick way of doing this script?

    Thank you

    In relation to the current database where the table lives, where will the new table "live"?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 7 posts - 1 through 6 (of 6 total)

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