SQL Create Table Scripts Automatically

Posted on 2011-04-19
Last Modified: 2012-05-11
Using SQL Management Studio, I know you can right-click a table -> Script table as -> Create To -> New Query Editor Window and then I can save that as a .sql file but how can I automate this?

For example, when I start a new project, I want to be able to run a script that will generate all of the table creation scripts for me so I can back them up in the documentation folder.
Question by:twcadmin
    LVL 16

    Accepted Solution

    You can right click the database -> tasks-> generate scripts

    this allows you to choose to script all tables . Not quite automatic but perhaps would help
    LVL 5

    Author Closing Comment

    This is very automatic. I was able to choose an options to create a new file for each object. It's not scriptable as far as I know but accomplishes when I am trying to do! Thanks!
    LVL 16

    Expert Comment

    by:Philip Pinnell

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now