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.
| Author |
Topic |
|
leozeo
Starting Member
2 Posts |
Posted - 2009-08-14 : 06:51:09
|
| I am trying to create a new database if it does not exists and if it exists then drop it and create it. I am trying to execute it from command line using .sql file as input.But it is throwing error "Could not locate entry in sysdatabases for database 'TEST_PUBLIC'. No entry found with that name. Make sure that the name is entered correctly."The command which i have used is:sqlcmd -S hostname,1433 -U abc -P xyz -i drop_database.sqlThe content in drop_database.sql file isUSE MASTERGOIF EXISTS(SELECT * FROM SYS.DATABASES WHERE NAME='TEST_PUBLIC')DROP DATABASE TEST_PUBLICGOCREATE DATABASE TEST_PUBLICUSE TEST_PUBLICGOwhat modification i have to do in this script to make it working?--Leozeo |
|
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-08-14 : 06:58:26
|
| CREATE DATABASE TEST_PUBLICGO <<<--- Add this GO. USE TEST_PUBLICGO |
 |
|
|
leozeo
Starting Member
2 Posts |
Posted - 2009-08-14 : 07:25:50
|
| thanks yellowBugcrap i did a silly mistake! |
 |
|
|
|
|
|