Showing posts with label lock. Show all posts
Showing posts with label lock. Show all posts

Friday, February 17, 2012

Database Locking

Hi
I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
SQL Server 2000
I want to lock the Database, full/complete Database,
there are more than 100 tables so locking them one by one would not be
the ideal solution(i think)
the requirement is
i - all currently logged in users must automatically logged out
( all open connections should be closed )
ii - all transactions should automatically rolled back
iii - no user can login while EOD is running
solution plz
Regards
Wow... You could start by looking into Pausing SQL server in BOL?
Immy
<atif.aqeel@.gmail.com> wrote in message
news:1128084372.490596.85200@.z14g2000cwz.googlegro ups.com...
> Hi
> I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
> SQL Server 2000
> I want to lock the Database, full/complete Database,
> there are more than 100 tables so locking them one by one would not be
> the ideal solution(i think)
> the requirement is
> i - all currently logged in users must automatically logged out
> ( all open connections should be closed )
> ii - all transactions should automatically rolled back
> iii - no user can login while EOD is running
> solution plz
> Regards
>
|||I assume you want to do this at the database level, not the SQL Server instance level. If so, use:
USE dbname
ALTER DATABASE dbname SET SINGLE_USER ROLLBACK IMMEDIATE
Do your job, and then set back to MULTI_USER
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
<atif.aqeel@.gmail.com> wrote in message news:1128084372.490596.85200@.z14g2000cwz.googlegro ups.com...
> Hi
> I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
> SQL Server 2000
> I want to lock the Database, full/complete Database,
> there are more than 100 tables so locking them one by one would not be
> the ideal solution(i think)
> the requirement is
> i - all currently logged in users must automatically logged out
> ( all open connections should be closed )
> ii - all transactions should automatically rolled back
> iii - no user can login while EOD is running
> solution plz
> Regards
>

Database Locking

Hi
I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
SQL Server 2000
I want to lock the Database, full/complete Database,
there are more than 100 tables so locking them one by one would not be
the ideal solution(i think)
the requirement is
i - all currently logged in users must automatically logged out
( all open connections should be closed )
ii - all transactions should automatically rolled back
iii - no user can login while EOD is running
solution plz
RegardsWow... You could start by looking into Pausing SQL server in BOL?
Immy
<atif.aqeel@.gmail.com> wrote in message
news:1128084372.490596.85200@.z14g2000cwz.googlegroups.com...
> Hi
> I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
> SQL Server 2000
> I want to lock the Database, full/complete Database,
> there are more than 100 tables so locking them one by one would not be
> the ideal solution(i think)
> the requirement is
> i - all currently logged in users must automatically logged out
> ( all open connections should be closed )
> ii - all transactions should automatically rolled back
> iii - no user can login while EOD is running
> solution plz
> Regards
>|||I assume you want to do this at the database level, not the SQL Server instance level. If so, use:
USE dbname
ALTER DATABASE dbname SET SINGLE_USER ROLLBACK IMMEDIATE
Do your job, and then set back to MULTI_USER
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
<atif.aqeel@.gmail.com> wrote in message news:1128084372.490596.85200@.z14g2000cwz.googlegroups.com...
> Hi
> I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
> SQL Server 2000
> I want to lock the Database, full/complete Database,
> there are more than 100 tables so locking them one by one would not be
> the ideal solution(i think)
> the requirement is
> i - all currently logged in users must automatically logged out
> ( all open connections should be closed )
> ii - all transactions should automatically rolled back
> iii - no user can login while EOD is running
> solution plz
> Regards
>

Database Locking

Hi
I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
SQL Server 2000
I want to lock the Database, full/complete Database,
there are more than 100 tables so locking them one by one would not be
the ideal solution(i think)
the requirement is
i - all currently logged in users must automatically logged out
( all open connections should be closed )
ii - all transactions should automatically rolled back
iii - no user can login while EOD is running
solution plz
RegardsWow... You could start by looking into Pausing SQL server in BOL?
Immy
<atif.aqeel@.gmail.com> wrote in message
news:1128084372.490596.85200@.z14g2000cwz.googlegroups.com...
> Hi
> I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
> SQL Server 2000
> I want to lock the Database, full/complete Database,
> there are more than 100 tables so locking them one by one would not be
> the ideal solution(i think)
> the requirement is
> i - all currently logged in users must automatically logged out
> ( all open connections should be closed )
> ii - all transactions should automatically rolled back
> iii - no user can login while EOD is running
> solution plz
> Regards
>|||I assume you want to do this at the database level, not the SQL Server insta
nce level. If so, use:
USE dbname
ALTER DATABASE dbname SET SINGLE_USER ROLLBACK IMMEDIATE
Do your job, and then set back to MULTI_USER
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
<atif.aqeel@.gmail.com> wrote in message news:1128084372.490596.85200@.z14g2000cwz.googlegroup
s.com...
> Hi
> I have to run EOD i.e End of Day, a VB 6.0 Application(ADO 2.6) with
> SQL Server 2000
> I want to lock the Database, full/complete Database,
> there are more than 100 tables so locking them one by one would not be
> the ideal solution(i think)
> the requirement is
> i - all currently logged in users must automatically logged out
> ( all open connections should be closed )
> ii - all transactions should automatically rolled back
> iii - no user can login while EOD is running
> solution plz
> Regards
>

Database Lock! Urgent Please!

Hello folks!
I'm with two locks on a database and I can't access others databases too, except the master.

I've tryed to kill the lock, but I didn't have sucess.

Please help me!!!
Cheers!
Rafael

SPID DBID OBJID INDID TYPE MODE STATUS
9 5 0 0 DB S GRANT
9 5 0 0 DB X GRANT
51 1 85575343 0 TAB IS GRANTWhat are the spids doing?

Are they yours?

Are you blocking yourself?

Did you look at sp_lock?|||Yes, this spid 9 is me.
But I'm not getting access. I've already disconected.
Take a look on the screenshot|||What do you mean when you say that you can't access other databases?|||I mean that I can't.

When I try to access a database via Entreprise, Query Analyser, etc..
like USE DB_Emplacamentos, DB_Cadastro, whatever, any database on server, my command or my screen keeps trying to connect to the database for the enternity.

I dunno why this is happing. I saw my SQL Server Logs and some erros like this was found:

* Using dynamic lock allocation. [500] Lock Blocks, [1000] Lock Owner Blocks.
* Skipping startup of clean database id 6
* Skipping startup of clean database id 7
* Skipping startup of clean database id 8
* Skipping startup of clean database id 9
* Skipping startup of clean database id 10
* Analysis of database 'DB_Emplacamentos' (5) is 3% complete (approximately 1726 more seconds)

Man, I'm thinking to reinstall the instance of SQL Server and try to restore the database. It is really, really strange.

Cheers!
Rafael|||OK. This looks like SQL 2000. If that is the case, then SPID 9 is not you. Any spid under 50 is a system process. It appears you have just rebooted this machine, and have the "long transaction blues". DB_Emplacamentos will need 20 minutes for just the analysis portion of recovery. Rolling forward, and rolling back could take a bit of time, too. This can happen when you do a lot of re-indexing, then reboot the server (only index creation statements and page allocations, and not all the page changes are recorded in the logs), or if you have an immense transaction that was halfway done when you rebooted. Out of curiosity, how but is DB_Emplacamentos?|||Oh, I imagine you are getting login errors something like "Can not open default database"?|||This database name is like DB_CarIDs.
I have a table with aprox. 45 million rows. It's a little bit big.LOL
The datafiles are around 20GB.

Well, I'll leave the database trying to restabish until tomorrow. If not, I'll start the McGiver's process of reastabilish a 20GB backup.LOL

Thank's for your help. I really appreciate that.

Rafael|||ROLLBACK is like a DOG, always know the way to comeback home!

My databases are allset now!!!
Yeaaah!!!;)

Tks all!

Cheers
Rafael

Database lock makes all Clients hold

We are using SQL2000 with SP3, Windows 2000 Svr Std with SP4
Sometimes, we found all clients had no response. Later, we found that the
all clients are waiting response from sql server.
Then in querry analyzer, we use this script:
select * FROM master..sysprocesses where status='sleeping' AND
waittype=0x000 AND open_tran > 0
and then we found out one computer is locking and after request that
computer logout the program, then, all clients can run again.
However, I have no idea why this case happen and I am still searching what's
the meaning the about select statement.
Can anyone help me?
IvanTalk to the person who wrote that program, as you have a bug in the application because it doesn't
and the transaction properly.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Ivan Kan" <ivankan@.no-ip.com> wrote in message news:uJg1Qb3lDHA.1740@.TK2MSFTNGP12.phx.gbl...
> We are using SQL2000 with SP3, Windows 2000 Svr Std with SP4
> Sometimes, we found all clients had no response. Later, we found that the
> all clients are waiting response from sql server.
> Then in querry analyzer, we use this script:
> select * FROM master..sysprocesses where status='sleeping' AND
> waittype=0x000 AND open_tran > 0
> and then we found out one computer is locking and after request that
> computer logout the program, then, all clients can run again.
> However, I have no idea why this case happen and I am still searching what's
> the meaning the about select statement.
> Can anyone help me?
> Ivan
>
>

Database Lock

This week one of our databases had a lock and our DBA's claim they don't know why. Are there any logging techniques that can show us sql statistics or problem sql statements?
Thanks,
-WillWell the best way is to use the age old method of Sql Profiler. You can capture all sorts of things (RPCs, Queries etc.)to a table, and then sort it based on reads, writes, most frequently called, cpu utilization, whatever. BOL has great documentation on how to use profiler. Other ways to find out what is happening on your server is to run any of the following statements

select * from master..sysprocesses
sp_who2 active
sp_who2
dbcc inputbuffer (spid)

Hope this helps|||Pigeon,

What is the difference between sp_who and sp_who2? I see the proc in my master database, but a search of Books Online comes up empty and likewise Microsoft's knowledge base.

blindman|||sp_who2 gives more performance related data (cpu, and read columns). It also is nicer for us folks who cling to the Results in Text option, rather than the grid. I don't think sp_who2 is "supported" anymore, as MS wants folks to use Enterprise Manager to do everything.|||Ha ha... you know, I didnt know there was an sp_who. I have only used sp_who2. It looks as though Mcrowley is right, there is a little bit of different info in there. As far as it not being supported... well I have it now, and it seems to work well, so enjoy it while it lasts? :)

Tuesday, February 14, 2012

Database level lock

Hi,

How do I lock entire database? I want an exclusive lock on the db by

a user
who is the dbo of that database only (not sa

user).

The

scenario is we have a web application and each week we need to do data

uploads (with etl). During this upload, the users accessing the website

should not be able to read data. This is why I want database lock.

Now

the catch here is, the application access the data using user say abc.

Abc is dbo for that database and the etl is also done by abc login. So

will db locking help in this case as the website can also read the data

being a abc user?

Thanks,
Tanmaya

You can use sp_dboption system stored procedure to put database in dbo use mode.

dbo use only

When true, only the database owner can use the database.

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/92d4714b-95bf-46af-b05e-759a7164f937.htm

Thanks,

Deepak Kumar

|||You can use the ALTER DATABASE Name SET RESTRICTED_USER command to switch the database to administrative mode.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

Database level lock

Hi,

How do I lock entire database? I want an exclusive lock on the db by

a user
who is the dbo of that database only (not sa

user).

The scenario is we have a web application and each week we need to do data uploads (with etl). During this upload, the users accessing the website should not be able to read data. This is why I want database lock.

Now the catch here is, the application access the data using user say abc. Abc is dbo for that database and the etl is also done by abc login. So will db locking help in this case as the website can also read the data being a abc user?

Thanks,
TanmayaYou can use the ALTER DATABASE Name SET RESTRICTED_USER command to switch the database to administrative mode.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

Database level lock

Actually, the scenario is we have a web application and each week we need to
do data uploads (with etl). During this upload, the users accessing the
website should not be able to read data. This is why I want database lock.
Now the catch here is, the application access the data using user say abc.
Abc is dbo for that database and the etl is also done by abc login. So will
db locking help in this case as the website can also read the data being a
abc user?
What can be done here?How do you do data upload? DTS,Bulk Insert what?
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message
news:elzYtFttGHA.3568@.TK2MSFTNGP05.phx.gbl...
> Actually, the scenario is we have a web application and each week we need
> to do data uploads (with etl). During this upload, the users accessing the
> website should not be able to read data. This is why I want database lock.
> Now the catch here is, the application access the data using user say abc.
> Abc is dbo for that database and the etl is also done by abc login. So
> will db locking help in this case as the website can also read the data
> being a abc user?
> What can be done here?
>|||Tanmaya Kulkarni wrote:
> Actually, the scenario is we have a web application and each week we need to
> do data uploads (with etl). During this upload, the users accessing the
> website should not be able to read data. This is why I want database lock.
> Now the catch here is, the application access the data using user say abc.
> Abc is dbo for that database and the etl is also done by abc login. So will
> db locking help in this case as the website can also read the data being a
> abc user?
> What can be done here?
>
One option would be to have the web app connect as user 'abc', and the
ETL process as user 'xyz'. When starting the ETL process, revoke access
from user 'abc', and restore it after ETL finishes.
Another option would be to create a new database, do the ETL into that
database, then detach/reattach the "new" database as the "live" database.
Tracy McKibben
MCDBA
http://www.realsqlguy.com

Database level lock

Yes with DTSHave you tried to issue
ALTER DATABASE dbname
SET RESTRICTED_USER
and then run the DTS Package
When the user reads the data it does not block writes ,sql server obtains a
share lock ,so anyway try running the above commad and see what si going on
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message
news:%23oazDUttGHA.1288@.TK2MSFTNGP02.phx.gbl...
> Yes with DTS
>

Database level lock

Hi,
How do I lock entire database? I want an exclusive lock on the db by a user
who is the dbo of that database only (not sa user).
Thanks,
TanmayaHmm, take a look at
ALTER DATABASE ...SET command along with SINGLE_USER | RESTRICTED_USER |
MULTI_USER
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message
news:%23bdnwHstGHA.3264@.TK2MSFTNGP03.phx.gbl...
> Hi,
> How do I lock entire database? I want an exclusive lock on the db by a
> user who is the dbo of that database only (not sa user).
> Thanks,
> Tanmaya
>|||This is a multi-part message in MIME format.
--=_NextPart_000_09A5_01C6B68C.705E4220
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
If I understand you correctly, you could do the following to limit the =database to dbo (and sa) roles only.
ALTER DATABASE MyDatabase
SET RESTRICTED_USER
And then when finished, return to regular use.
ALTER DATABASE MyDatabase
SET MULTI_USER
-- Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message =news:%23bdnwHstGHA.3264@.TK2MSFTNGP03.phx.gbl...
> Hi,
> > How do I lock entire database? I want an exclusive lock on the db by a =user > who is the dbo of that database only (not sa user).
> > Thanks,
> Tanmaya > >
--=_NextPart_000_09A5_01C6B68C.705E4220
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

If I understand you correctly, you =could do the following to limit the database to dbo (and sa) roles only.
ALTER DATABASE =MyDatabase
SET RESTRICTED_USER
And then when finished, return to =regular use.
ALTER DATABASE =MyDatabase
SET MULTI_USER
-- Arnie Rowland, =Ph.D.Westwood Consulting, Inc
Most good judgment comes from =experience. Most experience comes from bad judgment. - Anonymous
"Tanmaya Kulkarni" wrote in message news:%23bdnwHstGHA.3264@.TK2MSFTNGP03.phx.gbl...> Hi,> => How do I lock entire database? I want an exclusive lock on the db by a user => who is the dbo of that database only (not sa user).> > Thanks,> Tanmaya > >

--=_NextPart_000_09A5_01C6B68C.705E4220--

Database level lock

Hi,
How do I lock entire database? I want an exclusive lock on the db by a user
who is the dbo of that database only (not sa user).
Thanks,
TanmayaHmm, take a look at
ALTER DATABASE ...SET command along with SINGLE_USER | RESTRICTED_USER |
MULTI_USER
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message
news:%23bdnwHstGHA.3264@.TK2MSFTNGP03.phx.gbl...
> Hi,
> How do I lock entire database? I want an exclusive lock on the db by a
> user who is the dbo of that database only (not sa user).
> Thanks,
> Tanmaya
>|||If I understand you correctly, you could do the following to limit the datab
ase to dbo (and sa) roles only.
ALTER DATABASE MyDatabase
SET RESTRICTED_USER
And then when finished, return to regular use.
ALTER DATABASE MyDatabase
SET MULTI_USER
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message news:%23bdnwHstGHA.3
264@.TK2MSFTNGP03.phx.gbl...
> Hi,
>
> How do I lock entire database? I want an exclusive lock on the db by a use
r
> who is the dbo of that database only (not sa user).
>
> Thanks,
> Tanmaya
>
>|||Actually, the scenario is we have a web application and each week we need to
do data uploads (with etl). During this upload, the users accessing the
website should not be able to read data. This is why I want database lock.
Now the catch here is, the application access the data using user say abc.
Abc is dbo for that database and the etl is also done by abc login. So will
db locking help in this case as the website can also read the data being a
abc user?
What can be done here?|||How do you do data upload? DTS,Bulk Insert what?
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message
news:elzYtFttGHA.3568@.TK2MSFTNGP05.phx.gbl...
> Actually, the scenario is we have a web application and each week we need
> to do data uploads (with etl). During this upload, the users accessing the
> website should not be able to read data. This is why I want database lock.
> Now the catch here is, the application access the data using user say abc.
> Abc is dbo for that database and the etl is also done by abc login. So
> will db locking help in this case as the website can also read the data
> being a abc user?
> What can be done here?
>|||Tanmaya Kulkarni wrote:
> Actually, the scenario is we have a web application and each week we need
to
> do data uploads (with etl). During this upload, the users accessing the
> website should not be able to read data. This is why I want database lock.
> Now the catch here is, the application access the data using user say abc.
> Abc is dbo for that database and the etl is also done by abc login. So wil
l
> db locking help in this case as the website can also read the data being a
> abc user?
> What can be done here?
>
One option would be to have the web app connect as user 'abc', and the
ETL process as user 'xyz'. When starting the ETL process, revoke access
from user 'abc', and restore it after ETL finishes.
Another option would be to create a new database, do the ETL into that
database, then detach/reattach the "new" database as the "live" database.
Tracy McKibben
MCDBA
http://www.realsqlguy.com

Database level lock

Yes with DTSHave you tried to issue
ALTER DATABASE dbname
SET RESTRICTED_USER
and then run the DTS Package
When the user reads the data it does not block writes ,sql server obtains a
share lock ,so anyway try running the above commad and see what si going on
"Tanmaya Kulkarni" <tanmaya_kulkarni@.persistent.co.in> wrote in message
news:%23oazDUttGHA.1288@.TK2MSFTNGP02.phx.gbl...
> Yes with DTS
>