Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Wednesday, March 28, 2012

restore using isql

I have problems when trying to restore a database using the command line
isql program. I use a trusted connection and it says the database is in use
when no one is connected to it. Is there a problem trying to do this?
What is the default database for your trusted connection? If the default
database of your trusted connection is the database you trying to restore it
will v=be problem.
Also make sure no automated jobs periodically connecting the database.
Thanks
Ravi
"Tom Reis" wrote:

> I have problems when trying to restore a database using the command line
> isql program. I use a trusted connection and it says the database is in use
> when no one is connected to it. Is there a problem trying to do this?
>
>
|||The default database is master. Not the one I am trying to restore.
"Ravi" <ravishankart@.hotmail.com> wrote in message
news:203C4DFF-64B5-427E-A841-8AB5F8A51302@.microsoft.com...
> What is the default database for your trusted connection? If the default
> database of your trusted connection is the database you trying to restore
it[vbcol=seagreen]
> will v=be problem.
> Also make sure no automated jobs periodically connecting the database.
> --
> Thanks
> Ravi
>
> "Tom Reis" wrote:
use[vbcol=seagreen]
|||try EXEC sp_who2 and see there are any connections to the database
Thanks
Ravi
"Tom Reis" wrote:

> The default database is master. Not the one I am trying to restore.
> "Ravi" <ravishankart@.hotmail.com> wrote in message
> news:203C4DFF-64B5-427E-A841-8AB5F8A51302@.microsoft.com...
> it
> use
>
>
|||Tom,
From ISQL first go to SQL prompt using:-
ISQL -Usa -Ppassword (ENTER)
Now execute the below commands in sequence:-
ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
RESTORE DATABASE Command
GO
ALTER DATABASE <dbname> SET MULTI_USER
Note:
If the SQL Server version is 2000 then use OSQL instead of ISQL.
Thanks
Hari
SQL Server MVP
"Tom Reis" <reistom@.cdnet.cod.edu> wrote in message
news:%23Y8VXZbfFHA.3988@.TK2MSFTNGP10.phx.gbl...
>I have problems when trying to restore a database using the command line
> isql program. I use a trusted connection and it says the database is in
> use
> when no one is connected to it. Is there a problem trying to do this?
>
sql

restore using isql

I have problems when trying to restore a database using the command line
isql program. I use a trusted connection and it says the database is in use
when no one is connected to it. Is there a problem trying to do this?What is the default database for your trusted connection? If the default
database of your trusted connection is the database you trying to restore it
will v=be problem.
Also make sure no automated jobs periodically connecting the database.
--
Thanks
Ravi
"Tom Reis" wrote:
> I have problems when trying to restore a database using the command line
> isql program. I use a trusted connection and it says the database is in use
> when no one is connected to it. Is there a problem trying to do this?
>
>|||The default database is master. Not the one I am trying to restore.
"Ravi" <ravishankart@.hotmail.com> wrote in message
news:203C4DFF-64B5-427E-A841-8AB5F8A51302@.microsoft.com...
> What is the default database for your trusted connection? If the default
> database of your trusted connection is the database you trying to restore
it
> will v=be problem.
> Also make sure no automated jobs periodically connecting the database.
> --
> Thanks
> Ravi
>
> "Tom Reis" wrote:
> > I have problems when trying to restore a database using the command line
> > isql program. I use a trusted connection and it says the database is in
use
> > when no one is connected to it. Is there a problem trying to do this?
> >
> >
> >|||try EXEC sp_who2 and see there are any connections to the database
--
Thanks
Ravi
"Tom Reis" wrote:
> The default database is master. Not the one I am trying to restore.
> "Ravi" <ravishankart@.hotmail.com> wrote in message
> news:203C4DFF-64B5-427E-A841-8AB5F8A51302@.microsoft.com...
> > What is the default database for your trusted connection? If the default
> > database of your trusted connection is the database you trying to restore
> it
> > will v=be problem.
> >
> > Also make sure no automated jobs periodically connecting the database.
> >
> > --
> > Thanks
> > Ravi
> >
> >
> > "Tom Reis" wrote:
> >
> > > I have problems when trying to restore a database using the command line
> > > isql program. I use a trusted connection and it says the database is in
> use
> > > when no one is connected to it. Is there a problem trying to do this?
> > >
> > >
> > >
>
>|||Tom,
From ISQL first go to SQL prompt using:-
ISQL -Usa -Ppassword (ENTER)
Now execute the below commands in sequence:-
ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
RESTORE DATABASE Command
GO
ALTER DATABASE <dbname> SET MULTI_USER
Note:
If the SQL Server version is 2000 then use OSQL instead of ISQL.
Thanks
Hari
SQL Server MVP
"Tom Reis" <reistom@.cdnet.cod.edu> wrote in message
news:%23Y8VXZbfFHA.3988@.TK2MSFTNGP10.phx.gbl...
>I have problems when trying to restore a database using the command line
> isql program. I use a trusted connection and it says the database is in
> use
> when no one is connected to it. Is there a problem trying to do this?
>

restore using isql

I have problems when trying to restore a database using the command line
isql program. I use a trusted connection and it says the database is in use
when no one is connected to it. Is there a problem trying to do this?What is the default database for your trusted connection? If the default
database of your trusted connection is the database you trying to restore it
will v=be problem.
Also make sure no automated jobs periodically connecting the database.
Thanks
Ravi
"Tom Reis" wrote:

> I have problems when trying to restore a database using the command line
> isql program. I use a trusted connection and it says the database is in us
e
> when no one is connected to it. Is there a problem trying to do this?
>
>|||The default database is master. Not the one I am trying to restore.
"Ravi" <ravishankart@.hotmail.com> wrote in message
news:203C4DFF-64B5-427E-A841-8AB5F8A51302@.microsoft.com...
> What is the default database for your trusted connection? If the default
> database of your trusted connection is the database you trying to restore
it[vbcol=seagreen]
> will v=be problem.
> Also make sure no automated jobs periodically connecting the database.
> --
> Thanks
> Ravi
>
> "Tom Reis" wrote:
>
use[vbcol=seagreen]|||try EXEC sp_who2 and see there are any connections to the database
Thanks
Ravi
"Tom Reis" wrote:

> The default database is master. Not the one I am trying to restore.
> "Ravi" <ravishankart@.hotmail.com> wrote in message
> news:203C4DFF-64B5-427E-A841-8AB5F8A51302@.microsoft.com...
> it
> use
>
>|||Tom,
From ISQL first go to SQL prompt using:-
ISQL -Usa -Ppassword (ENTER)
Now execute the below commands in sequence:-
ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
RESTORE DATABASE Command
GO
ALTER DATABASE <dbname> SET MULTI_USER
Note:
If the SQL Server version is 2000 then use OSQL instead of ISQL.
Thanks
Hari
SQL Server MVP
"Tom Reis" <reistom@.cdnet.cod.edu> wrote in message
news:%23Y8VXZbfFHA.3988@.TK2MSFTNGP10.phx.gbl...
>I have problems when trying to restore a database using the command line
> isql program. I use a trusted connection and it says the database is in
> use
> when no one is connected to it. Is there a problem trying to do this?
>

Monday, March 26, 2012

Restore through Job or DTS

I try to schedule either a job or a DTS package that will restore a db from
backup. No other connection exist on that db but apparently I receive the
message that Restore failed because exclusive access to the db could not be
obtained. I assume that the connection that is counted is the connection of
the job itself.
Can anyone help ?Hi ,
Your message confirms that there is some existing connection in the database
when you are try to restore. So please add the below script along with your
DTS package.
use master
go
declare @.x varchar(255)
select @.x = @.x + " kill " + convert(varchar(5), spid)
from master.dbo.sysprocesses
where dbid = db_id ('dbname')
exec (@.x)
go
Please replace the dbname with your database name in the script.
Thanks
Hari - MCDBA
US Software
Trivandrum
"Andreas" <andreasy@.netu.com.cy> wrote in message
news:uZ7hY6aVDHA.2224@.TK2MSFTNGP09.phx.gbl...
> I try to schedule either a job or a DTS package that will restore a db
from
> backup. No other connection exist on that db but apparently I receive the
> message that Restore failed because exclusive access to the db could not
be
> obtained. I assume that the connection that is counted is the connection
of
> the job itself.
> Can anyone help ?
>