Finishing one query before beginning another

Finishing one query before beginning another

Post by Anthony J Biondo J » Sun, 30 Mar 2003 07:27:38



Hi I want to run a statement like the following

Delete from table_name1 Where id = 1

Insert into table_name1 (x, y) values (1, 2)

the statements are there for example but I want to make the delete fully
complete before the insert starts.  How can I achieve this?

Any suggestions would be appreciated.

Thanks,
Anthony Biondo Jr

 
 
 

Finishing one query before beginning another

Post by Anith Se » Sun, 30 Mar 2003 07:31:34


If they are in the same batch or SP it will be executed one after another.
If they are in different batches and you are trying to avoid concurrency,
use proper locking hints as per the requirements. Note that exclusive locks
will be defaulted to DELETE statement. See details about locking and related
topics like escalation etc in SQL Server Books Online.

--
- Anith
(Please respond only to newsgroups)

 
 
 

Finishing one query before beginning another

Post by Vinod » Sun, 30 Mar 2003 14:28:51


By default this is the behaviour you would have ... If you could post the complete code then someone here would come with the solution for the exact requirement.

--
HTH,
Vinod Kumar
MCSE, DBA, MCAD
SCT Software Solutions


Quote:> Hi I want to run a statement like the following

> Delete from table_name1 Where id = 1

> Insert into table_name1 (x, y) values (1, 2)

> the statements are there for example but I want to make the delete fully
> complete before the insert starts.  How can I achieve this?

> Any suggestions would be appreciated.

> Thanks,
> Anthony Biondo Jr

 
 
 

1. Waiting for SQL Server query to finish??

I have an application in MS Access that retrieves data from a large database
to a local Access table so that viewing is done on local tables. I have
found a weird problem in that I run queries to append the records into the
local tables and the code continues apparently before the query finishes and
I open the form and there is no data. However, I open the form after 5
seconds and the data is there. Is there not a way to have the form open only
after the append query is actually finished or is there something else I am
missing?

Bob Baldwin, MSCP

2. Destroy Objects

3. StillExecuting returning False even though query hasn't finished

4. Navision / Sql Database problem

5. ABORT A LONG QUERY BEFORE IT FINISH

6. SIGILL 4 error

7. MDAC2.6 + Windows95 BIG performance problem

8. BEGIN TRANSACTION vs. BEGIN

9. begin/end begin tran/commit in while

10. Splitting a large query up into slices, and handing them off one by one

11. begin tran and dynamic query

12. SQL query - Get one record if it exists else get another one