IgO
IgO

Reputation: 133

Generate create table SQL script for all tables in database

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

Any suggestions?

Upvotes: 12

Views: 31193

Answers (2)

Dale K
Dale K

Reputation: 27201

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.

Upvotes: 0

Rahul
Rahul

Reputation: 77846

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.

Upvotes: 36

Related Questions