Showing posts with label sp_detach_db. Show all posts
Showing posts with label sp_detach_db. Show all posts

Monday, February 13, 2012

Attaching and Detaching Databases

in the BOL I have read the "Attaching and Detaching Databases"
in the query analyzer (pointing to the master db) I run (as sa)
EXEC sp_detach_db 'Mydb', 'true'
I got this message which is not covered.
Server: Msg 3702, Level 16, State 1, Line 1
Cannot drop the database 'mydb' because it is currently in use.
DBCC execution completed. If DBCC printed error messages, contact your
system administrator.
The database has no connections to it other than the Enterprise manager.
what am I missing.Do you have the database open (i.e. browsing the objects) in Enterprise
Manager? Is the database open in Query Analyzer and "collapsed". If so,
there's your connection.
You can also run sp_who to find out what connections are currently attached.
-Morgan
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:u5WMY2lcDHA.2112@.TK2MSFTNGP10.phx.gbl...
> in the BOL I have read the "Attaching and Detaching Databases"
> in the query analyzer (pointing to the master db) I run (as sa)
> EXEC sp_detach_db 'Mydb', 'true'
> I got this message which is not covered.
> Server: Msg 3702, Level 16, State 1, Line 1
> Cannot drop the database 'mydb' because it is currently in use.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>
> The database has no connections to it other than the Enterprise manager.
> what am I missing.
>|||Hi,
>>other than the Enterprise manager.
Even that is a connection.Try sp_who and make sure to kill the spids
accessing the database.
--
Dinesh.
SQL Server FAQ at
http://www.tkdinesh.com
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:u5WMY2lcDHA.2112@.TK2MSFTNGP10.phx.gbl...
> in the BOL I have read the "Attaching and Detaching Databases"
> in the query analyzer (pointing to the master db) I run (as sa)
> EXEC sp_detach_db 'Mydb', 'true'
> I got this message which is not covered.
> Server: Msg 3702, Level 16, State 1, Line 1
> Cannot drop the database 'mydb' because it is currently in use.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>
> The database has no connections to it other than the Enterprise manager.
> what am I missing.
>|||thanks for you answers:
Does not sp_who show the connections to the server?
do I have to remove all connection to the server just to move one DB?
This seems illogical sense the default is always logged in.
I looked at the sp_detach_db and it seems the error is being generated in
the
DBCC DETACHDB
which I don't know enough about, to go poking around.
I looked up in the BOL and it does not show in SQL 7.0 version.
in looking at
DROP DATABASE (T-SQL)
it mentions something about offline.
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:u5WMY2lcDHA.2112@.TK2MSFTNGP10.phx.gbl...
> in the BOL I have read the "Attaching and Detaching Databases"
> in the query analyzer (pointing to the master db) I run (as sa)
> EXEC sp_detach_db 'Mydb', 'true'
> I got this message which is not covered.
> Server: Msg 3702, Level 16, State 1, Line 1
> Cannot drop the database 'mydb' because it is currently in use.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>
> The database has no connections to it other than the Enterprise manager.
> what am I missing.
>

Thursday, February 9, 2012

attach?backup?export?

what're the difference among these three functions?
I can use sp_detach_db/sp_attach_db SP to attach a db in sqlserver. But
what SP is in oracle to do the same work? If i want to migrate db from
sqlserver to oracle. how to do the attach function in oracle?
tks
Hi Napo,
You can't use detach/attach or backup/restore to move a database from sql
server to oracle. You need to recreate your schema on the oracle system and
then move your data there. Easiest starting point (if you have Enterprise
Manager) would likely be to use DTS (Data Transformation Services) to help
you with this. You can use it like a "data pump" as long as your copy of
Enterprise Manager has access to both the sql server and oracle systems.
(You can connect to oracle via an OLEDB driver).
If your application is complex, you might need to look at some 3rd party
tools that help with these migrations.
HTH,
Greg Low [MVP]
MSDE Manager SQL Tools
www.whitebearconsulting.com
"Napo" <Napo@.discussions.microsoft.com> wrote in message
news:D346C199-2716-4138-935A-CB7D8F444976@.microsoft.com...
> what're the difference among these three functions?
> I can use sp_detach_db/sp_attach_db SP to attach a db in sqlserver. But
> what SP is in oracle to do the same work? If i want to migrate db from
> sqlserver to oracle. how to do the attach function in oracle?
> tks
|||Hi Greg,
Thank you for your reply.
My current job is to investigate the solution of migrate db from
sqlserver to oracle. My key eyepoint is .net client code but not DB
administration.At current system, they use ado.net to execuate sqlserver
detach/attach. I just want to know if i can write code to hot backuo(or cold
backup) oracle db using by ado.net(c#).
"Greg Low [MVP]" wrote:

> Hi Napo,
> You can't use detach/attach or backup/restore to move a database from sql
> server to oracle. You need to recreate your schema on the oracle system and
> then move your data there. Easiest starting point (if you have Enterprise
> Manager) would likely be to use DTS (Data Transformation Services) to help
> you with this. You can use it like a "data pump" as long as your copy of
> Enterprise Manager has access to both the sql server and oracle systems.
> (You can connect to oracle via an OLEDB driver).
> If your application is complex, you might need to look at some 3rd party
> tools that help with these migrations.
> HTH,
> --
> Greg Low [MVP]
> MSDE Manager SQL Tools
> www.whitebearconsulting.com
> "Napo" <Napo@.discussions.microsoft.com> wrote in message
> news:D346C199-2716-4138-935A-CB7D8F444976@.microsoft.com...
>
>