What is the SQL Server compatible command for Mysql SHOW CREATE TABLE?

Asked

Viewed 302 times

0

What would be the command in SQL Server to view the script for the creation of a given table?

With a result more or less like this:

+------------+---------------------------------------------------+
| table_name |                 create_statement                  |
+------------+---------------------------------------------------+
| customers  | CREATE TABLE customers (                          |
|            |                                                   |
|            |     id INT NOT NULL,                              |
|            |                                                   |
|            |     email STRING NULL,                            |
|            |                                                   |
|            |     CONSTRAINT "primary" PRIMARY KEY (id ASC),    |
|            |                                                   |
|            |     UNIQUE INDEX customers_email_key (email ASC), |
|            |                                                   |
|            |     FAMILY "primary" (id, email)                  |
|            |                                                   |
|            | )                                                 |
+------------+---------------------------------------------------+
  • the simplest option is to go in the "Script" menu, but this result ai does not exist in any table, you will have to combine the results to generate it

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.

1 answer

1

There’s no way, you can get the information you want in other ways, for example

sp_help customers

Or

exec sp_columns customers

I put in the Github for future reference.

Or you can get something similar in the GUI by going on Script Table As ->Create.

As SO.

  • thanks for your return. These commands I already knew. The closest I need is when I select in sys.all_sql_modules, however the Definition column shows the creation script for the views and procedures. I was really needing the script to create a certain table.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.