views:

138

answers:

1

I am using help of SqlServer.Management.Smo to rename an attached MS-SQL database.

Dim db As New Database = ActiveSQLServer.Databases(OLD_NAME)
db.ExecuteNonQuery("ALTER DATABASE " & OLD_NAME & " SET SINGLE_USER WITH ROLLBACK IMMEDIATE")
db.ExecuteNonQuery("ALTER DATABASE " & OLD_NAME & " MODIFY NAME = " & NEW_NAME)

The problem is that after renaming the database is set as a Single User.

So what am i doing wrong?

+1  A: 

Your 2nd statement is setting it to single user.

ozczecho
Chocol8
:-) sometimes helps to have a new pair of eyes look at the problem...
ozczecho
LOL - easiest question I've seen in ages. Don't worry, we've all done that at some point. :-)
Christian Hayter