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
 creating and immediately using db

Author  Topic 

etrek42
Starting Member

3 Posts

Posted - 2011-12-20 : 17:26:12
hi,

i wrote a query:

CREATE DATABASE MyDataBase

USE MyDataBase

but i get an error saying the database dosn't exist!!!

help please :)

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-12-20 : 19:35:45
CREATE DATABASE MyDataBase
go
USE MyDataBase

Be One with the Optimizer
TG
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-12-20 : 19:37:29
Use a batch separator between the two statements, as in
CREATE DATABASE MyDataBase
GO
USE MyDataBase;
If you parse the query it would still appear as though there is an error, but you can execute it successfully.

Go to Top of Page

etrek42
Starting Member

3 Posts

Posted - 2011-12-21 : 04:26:48
thanks soooooo much!!!!!
I thought all i was missing was a word :)
Go to Top of Page
   

- Advertisement -