INSERT does it cause locks?

  • I need to query information from an oracle database frequently, and I am collecting this data in a sql server database for analysis.

    Since I constantly query using openquery, I made some permanent temp tables for this purpose, with a key defined inside the stored procedure that does the population.

    My question, is does the table get locked when performing a query like:

    declare @GUID uniqueidentifier

    select @GUID = newid()

    insert into my_temp ([guid], [value_1], [value_2])

    select @GUID, * from openquery(linked_server, '

    select a,b from oracle_table

    where condition = ''test''

    ')

    Regards

    Martin

  • Sure, there will be locks on the table being inserted into while the insert happens. Depending on the indexes and some other factors the type of lock will vary from row to page to table. The database has to take some kind of locks to keep you from getting dirty and phantom reads and conflicting updates/inserts.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply