Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 locking table

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2008-05-06 : 07:07:38
hi,
I am running a sql job that select data from one database (multiple table) and inserts into another database (1 table)

I have a problem with the way it is locking the tables I am selecting from !

my query is like :

insert into testdb.dbo.tabletest

select * from
livedb.dbo.tablex
inner join liveb.dbo.table1 on tablex.id=table1.xid


It seems to be locking the table and blocking other users from accessing the table.

suppose my question is why is the select locking the table ?

sam13
Starting Member

6 Posts

Posted - 2008-05-06 : 07:34:39
Use With(NOLOCK) option on tablex. As a side note, NOLOCK queries also run the risk of reading "phantom" data, or data rows that are available in one database transaction read but can be rolled back in another.
Go to Top of Page
   

- Advertisement -