Reputation: 215
I use sql server 2014 and with following piece of code:
if db_id('handel') is not null
drop database handel;
create database handel;
use handel;
I get the error: Database 'handel' does not exist. Make sure that the name is entered correctly.
on line use handel
, which blows my mind a bit, as just a line before I create said database. Could anyone please help?
Upvotes: 1
Views: 1620
Reputation: 3216
You missed GO Keyword:
if db_id('handel') is not null
drop database handel;
create database handel;
GO
use handel;
Upvotes: 6