Introduction
Many times sql developers and dbas are given the task of scripting and standardizing code and checking into a source control system after the objects, in this case tables, are already defined in sql server. This can be achieved by right clicking on the object and then selecting the "Script Table As" option; however, this option creates a file that needs modifcation and proper formatting in most cases. I have taken the time to createa script that generates the create table DDL in a more readable, tabbed format.
How to use
Simply enter the table name in the script where the @TableName paramter is and run. The script will generate the appropriate existence check, the create table statement with datatypes and nullability, any defaults defined, and the primary key definition after the create table statement. The script will account for any compound primary keys with up to 16 columns defined. The script will not explicitly define the collation, so the default defined is used. And, the script currently does handle foreign keys. This should save the user some time and effort for this task.