How to write a script to get the generated scripts of table definition

  • Hi,

    I know I can use EM > mydatabase > tables > right click mytable > create script

    to view the definition of mytable such as

    create table dbo.mytable

    (

    column1 int not null,

    column2 varchar(50),

    column3 bit

    )

    Now my question is how can I use Query Analyzer to write a script with for table named as mytable to view the generated script for mytable's definition as above codes?

    Thanks so much.

  • I'm not sure if I follow you, but in Query Analyzer you can also right click the table name to generate the 'create' script for the table.

    Is this what you mean, or do you want to know some SQL commands to generate the table script automatically?

    If it was easy, everybody would be doing it!;)

  • Trader Sam (3/20/2008)


    I'm not sure if I follow you, but in Query Analyzer you can also right click the table name to generate the 'create' script for the table.

    Is this what you mean, or do you want to know some SQL commands to generate the table script automatically?

    Yes, I want some SQL commands to generate the table script automatically or programmatically instead of right click a table to generate the 'create' script for the table In Query Analyzer. It is tedious and time consuming to make right-clicks if I have 70 tables to view their generated (created) scripts.

    Hope you or somebody can help me. Thanks in advance.

  • In Enterprise Manager, you can generate a single script for ALL tables in the database (all in a single file).

    Highlight the DB name, rt click, select 'generate SQL script', click 'Show All' in dialog, check 'All Tables' in dialog.

    If it was easy, everybody would be doing it!;)

  • You can do it from within Enterprise manager. Right-click on the DB, all tasks, Generate SQL Script... follow the wizard. It will dump them all into a directory of your choosing.

    Of course - you have to open them all one by one ,etc...

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thank you, everybody.

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

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