Question : Create multiple SQL Tables at once rather than a single table at a time

Hi,

I am creating a number of SQL Tables for an application and was wondering if there was a way of creating them in one single instance rather than having to painstakingly have to create each one in VS2008 or SQL Server 2008R2?

Any help is very much appreciated.

Thanks

Answer : Create multiple SQL Tables at once rather than a single table at a time

There's a really neat feature in SQL 2005 and 2008 that can help you with this.  Particularly if you are new to T-SQL.

Create the first table manually using SQL Server Management Studio.  You seem to be confident in doing this, right?

Once the table is created, you can right-click on it and choose Script Table As.  Choose the sub-option Create to new query editor window.

You can then just edit the table name and run the query to create the new table.

If you think you'll need to do it again, you can append them all into one query.

The thing to look out for is that the query will throw an error if the table already exists (like your first table).  You can code around this easily, but it's outside the scope of your question and not required in my opinion, in the interests of keeping it simple.

Random Solutions  
 
programming4us programming4us