Script Object -- data, not just layout ?

  • Currently I open Query Analyzer,

    right click on the table I want, left

    click "Script object to new window as",

    left click "Insert", and the database layout

    script is generated.

    How can I automatically generate the

    following script from "data" that

    is already in the table ?

    CREATE TABLE test_table (FName nvarchar(100), LName nvarchar(100))

    INSERT INTO test_table (FName, LName) values ('John','Doe')

    INSERT INTO test_table (FName, LName) values ('Jane','Doe')

  • You can get a tool or a stored procedure to do this. As part of our main product DB Ghost we give away a data and schema scripter which will create the insert statements for a table as well as schema scripting. There is also a link in the help file to a stored procedure (free) that can also be used. All you have to do is get the evaluation copy of DB Ghost and the data and schema scripter will install which is free and distributable which also includes a COM interface for programmers.

     

     

    regards,

    Mark Baekdal

    http://www.dbghost.com

    http://www.innovartis.co.uk

    +44 (0)208 241 1762

    Database change management for SQL Server

     

     

     

  • http://vyaskn.tripod.com/code/generate_inserts.txt

     

    a stored procedure which generates insert statements, complete with IDENTITY_INSERT ON/OFF for the primary keys, and lots of parameters to make it flexible.

     

    HTH

    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!

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

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