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)
 Programmatically creating databases

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-29 : 10:31:56
Adam writes "I need to programmatically create a database in SQL Server 7. To do this I need to decide the filename at runtime. This means that I need to execute code like:

CREATE DATABASE automailer
ON ( name = automailer_Data,
filename = @dbfolder,
size = 50 )
LOG ON ( name = automailer_Log,
filename = @logfolder,
size = 10 )

where @dbfolder and @logfolder are defined earlier. However, I get the following error message:

Incorrect syntax near '@dbfolder'.

I am guessing that I need to do something special to use a variable as the filename, but I don't know what!

Thanks in advance."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-04-29 : 11:18:28
Dynamic SQL to the rescue!

http://www.sqlteam.com/item.asp?ItemID=4599
http://www.sqlteam.com/item.asp?ItemID=4619

Go to Top of Page
   

- Advertisement -