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
 Transact-SQL (2000)
 Create database with parameters?

Author  Topic 

Frances
Starting Member

20 Posts

Posted - 2005-02-16 : 06:04:15
Hi all,

does anyone know how I can make a stored which creates a database with a name that I specify as a variable?

Example:

CREATE PROC Create_Database (@name varchar(100))
AS
CREATE DATABASE @name

GO

Unfortunately, the '@name' isn't accepted... Any ideas?

Thank you :)

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-16 : 06:06:59
try:
exec('CREATE DATABASE ' + @name)

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Frances
Starting Member

20 Posts

Posted - 2005-02-16 : 06:20:40
Thanks very much, that works like a charm

Thank you
Go to Top of Page
   

- Advertisement -