Generate create table SQL script for all tables in database

22,596

Solution 1

In SQL Server Management Studio(SSMS)

Right click on the DB_NAME -> Select Task -> Select Generate Script.

Follow along the presented wizard and select all tables in that database to generate the scripts.

Solution 2

Use a Visual Studio SQL Server Database Project as follows:

  1. Create a Visual Studio SQL Server Database Project.

enter image description here

  1. From the Project Menu, select Import > Database ...

  2. Right click on the project and click publish.

Share:
22,596
IgO
Author by

IgO

Updated on November 29, 2020

Comments

  • IgO
    IgO over 3 years

    I need to create the SQL code that in it's output will return the CREATE TABLE SQL for all tables in current database.

    Any suggestions?