Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamically Naming Databases Using SQL

Author  Topic 

nsteiner
Starting Member

13 Posts

Posted - 2001-03-29 : 12:19:55
***USING SQL Server 2000***

I am trying to create a stored proc that creates a new database, and have that new database named based on user input.

What I have is:
***********************************

Alter Procedure sp_CreateNewDB
/**This is going to be the dbName a user has entered on a web site form**/
@newDBName varchar(25)

As
CREATE DATABASE TempDB

/**I tried:
CREATE DATABASE @newDBName
But received an error**/

***********************************

So, right now I am creating the TempDB, then calling sp_renamedb, then having to modify the log and data file names to reflect the user-named db - having quite finished yet.

How can I create a new db with a variable name??



   

- Advertisement -