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
 General SQL Server Forums
 New to SQL Server Programming
 How to Prompt for DBNAME in Script

Author  Topic 

mshad
Starting Member

1 Post

Posted - 2009-06-26 : 16:10:11
Im very new to SQL scripting.
I have a script in which i want to get the prompt for DBNAME. SO when i run the script it should ask me what is the name of the NEW DB and not hardcoded in the script. Is there a command or way to do this:



CREATE DATABASE %dbname%
ON
( NAME = %dbname%,
FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\%dbname%.mdf',
SIZE = 2MB,
MAXSIZE =unlimited ,
FILEGROWTH = 1MB )
LOG ON
( NAME = '%dbname%_log',
FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Log\%dbname%_log.ldf',
SIZE = 10MB,
MAXSIZE = unlimited,
FILEGROWTH = 10% )
GO

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-26 : 16:43:27
NO.
T-SQL is not interactive.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-27 : 01:02:22
you can however write a procedure which accepts dbname as a parameter and then create a dynamic sql string using the variable and create the db. even then the interactive part has to done at your front end application
Go to Top of Page
   

- Advertisement -