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
 Drop Database

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2010-10-06 : 09:57:24
Hello,

I have the following:

if exists (select name from sys.databases where name = @DatabaseName)
begin
alter database @DatabaseName set single_user with rollback immediate
go
drop database @DatabaseName
go
end

I get an error on the second go:
Incorrect sintax near go.

Basically I am checking if the database exists. If yes then close all connections to it and drop it.

What am I missing?
Am I closing the connections correctly?

Thanks,
Miguel

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2010-10-06 : 10:09:23
Same reason as in this thread: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151157

Harsh Athalye
http://www.letsgeek.net/
Go to Top of Page
   

- Advertisement -