You are on page 1of 1

Tables

The start of each table creation script is as simple as CREATE TABLE:

2 SELECT @Schema_Build_Text = 'USE [' + @Database_Name + '];' + '

4'+

5 'CREATE TABLE [' + TABLE_DATA.Schema_Name + '].[' + TABLE_DATA.Table_Name + ']('

6 FROM @Tables TABLE_DATA

7 WHERE TABLE_DATA.Schema_Name = @Schema_Name_Current

8 AND TABLE_DATA.Table_Name = @Table_Name_Current

This first section sets the database context to whatever database we are analyzing and then puts
together the CREATE TABLE statement, filtered on the current table and schema we are working
on. Square brackets are used around all object names, which ensures that we are able to manage
any that have spaces in their names.

You might also like