query for seeing the predefined table query

  • please tell any one , how i see the query which is used for creating a table

  • shubhamagrawal.107 (5/23/2012)


    please tell any one , how i see the query which is used for creating a table

    SQL Server does not keep the query used for creating a table.

    But you can generate script if you need.

    You can configure trigger to track DDL statements.

  • what are the requirements?

    is it an object which exists on ServerA and you need to script it to move it to ServerB? If so right click the object and use the script object as

    is it an object has been created and you want to know by who, when and how? If so check the default trace, it might be in there but it might not, query the system table you might get what you need, or impliment a custom DDL trigger

    if its learning how to create table then look in your favourite search engine or BOL for the keywords CREATE TABLE

  • actually, i created a table before some time and now i want to see what query i used to create that table.

    now tell me can i see the query.....

  • script the table using the script table as function when you right click the table

  • can you please give me the query as a example

  • there is no query, use SSMS, connect to server, expand database, expand tables, right click table, hover over script table as, click new query window

  • shubhamagrawal.107 (5/23/2012)


    actually, i created a table before some time and now i want to see what query i used to create that table.

    now tell me can i see the query.....

    Just follow these steps:

    1. Open SSMS.

    2. Connect to you Server.

    3. Open Database you want to view in Tree View.

    4. Open Tables in Tree View.

    5. Right Click the table and select "Script Table As"-->"Create To"-->"New Query Window".

    6. And Voilla!!!!!.....there you have your create table query. 😀

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

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

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