Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Create multiple SQL tables with script

Avatar of scfits
scfitsFlag for United States of America asked on
Windows BatchMicrosoft SQL Server 2005VB Script
6 Comments1 Solution374 ViewsLast Modified:
I have a text file with one column of table names with a carriage return as a delimiter:

Table1
Table2
Table3

A simple CREATE TABLE script would have a variable @TableName and the script would look something like this.  I will not be creating tables in the databases at the moment.

DECLARE @TableName varchar(20)
@TableName = c:\TextFile.txt (something like this, I don't know how to work out this logic)

CREATE DATABASE [@TableName] ON  PRIMARY
( NAME = N'@TableName', FILENAME = N'E:\SQL_DBs\@TableName.mdf' )
 LOG ON
( NAME = N'@TableName_log', FILENAME = N'F:\SQL_Logs\@TableName_log.ldf' )
GO

Any help would be appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Emes
EmesFlag of United States of America imageData archithect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers