Hi,
On calling the source attached below to drop sql database, I get the
following error randomly,
"Cannot detach the database 'DBNAME' because it is currently in use.
[Microsoft OLE DB Provider for SQL Server]"
I am not sure what am I doing wrong here.
Any pointers in this regard will be appreciated.
Regards,
Usman
con.Execute "use master"
' Get list of processes blocking this catalog and try to
kill all them
Set rs = con.Execute("sp_who2", , adCmdStoredProc)
If Err.Number = 0 And Not rs Is Nothing Then
While Not rs.EOF
If StrComp(rs("dbname"), sCatalog, vbTextCompare)
= 0 Then
con.Execute "kill " & rs("spid")
' Ignore errors
Err.Clear
End If
rs.MoveNext
Wend
rs.Close
End If
con.Execute "sp_detach_db('" & sCatalog & "', 'true')", ,
adCmdStoredProc ''''''''$$$$$$$$$$$$$$$
Hello,
Do the below command from ISQL window
USE MASTER
GO
ALTER DATABASE <DBNAME> Set SINGLE_USER with Rollback Immediate
GO
DROP Database <dbname>
Thanks
Hari
"Usman" <khanusman@.gmail.com> wrote in message
news:1170770913.673583.11240@.s48g2000cws.googlegro ups.com...
> Hi,
> On calling the source attached below to drop sql database, I get the
> following error randomly,
> "Cannot detach the database 'DBNAME' because it is currently in use.
> [Microsoft OLE DB Provider for SQL Server]"
> I am not sure what am I doing wrong here.
> Any pointers in this regard will be appreciated.
> Regards,
> Usman
>
> con.Execute "use master"
> ' Get list of processes blocking this catalog and try to
> kill all them
> Set rs = con.Execute("sp_who2", , adCmdStoredProc)
> If Err.Number = 0 And Not rs Is Nothing Then
> While Not rs.EOF
> If StrComp(rs("dbname"), sCatalog, vbTextCompare)
> = 0 Then
> con.Execute "kill " & rs("spid")
> ' Ignore errors
> Err.Clear
> End If
> rs.MoveNext
> Wend
> rs.Close
> End If
> con.Execute "sp_detach_db('" & sCatalog & "', 'true')", ,
> adCmdStoredProc ''''''''$$$$$$$$$$$$$$$
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment