How to view query that was used to create a table?

Topman picture Topman · Apr 4, 2015 · Viewed 11.4k times · Source

I create about 15 tables and create relationships and constraints among them using Wizard in SQL Server 2012 express

Now i want to see the query that is used to create those tables including relationships and constraints. Can u provide help?

Thank you.

Answer

Sergey Kalinichenko picture Sergey Kalinichenko · Apr 4, 2015
  1. Connect to your database using SQL Server Manager Studio
  2. Right-click the table or the view in the Object Explorer panel
  3. From the context menu choose Script Table as.../CREATE to.../< SomeDestination >
  4. Choose a destination (a file, the clip board, etc.)

Screenshot

This would give you access to the DDL SQL that can be used to create this table.