0

I have a database with many tables that have been periodically updated over the years (not by me). I would like to make CREATE TABLE scripts for all of the tables.

It appears Script table as... only works on a single table at a time. Is there a way to script out all of the tables in a database?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98

1 Answers1

6
  1. In SSMS, Right Click the Database, go to Tasks -> Generate Scripts.

  2. In the second window, select Select specific database objects and tick Tables: enter image description here

    1. Choose where you want the results to to go, File, Clipboard or a new Query Window

    2. Check all the settings are correct

    3. Finish. Consume your file/clipboard.

Thom A
  • 88,727
  • 11
  • 45
  • 75
  • Most excellent... and (IMHO) somewhat well hidden. This option should be on the Tables tab, and/or multiple-select. – Maury Markowitz Feb 11 '20 at 14:54
  • *"This option should be on the Tables tab,"* Why would you want a tool that can generate the DDL for *any* of the database's objects to to on the tables node? At Database level makes the most sense. I wouldn't be looking to script out all the database's Views and SP in the tables node of the object explorer, I'd be looking at Database Level. it makes sense where it is, as you want to script out all the database's objects. – Thom A Feb 11 '20 at 14:59