Solved

Table Locks and Transaction Log Disabling

Posted on 2002-04-02
2
200 Views
Last Modified: 2012-06-22
I have two stored procedures.  The first dynamically generates a crosstab table (called tbl_Crosstab) based upon a specified date range.  The second gets the data out of this new table, formats it and generates the data for XML output.  These commands are shown below.  The Create SP is used by other areas of the DB so I can't include the display in that SP or use temporary tables.  I am worried that I need to lock the newly created tbl_Crosstab until the data is grabed by the Display SP so that any other resource is not grabbing invalid data.  How do I do this?  Also, if I am creating this new table, are all of the entries being added to the transaction log for the DB?  These values do not need to be backed up (since they change constantly and are only used when created) and they could be creating large transaction logs.  How do I also disable the logging of the creation of the table and data inserts?

EXECUTE usp_CreateCrossTabTable @StartDate, @EndDate
EXECUTE usp_DisplayCrossTabTable_ForXML
0
Comment
Question by:bmccleary
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
nigelrivett earned 50 total points
ID: 6913817
You cannot stop entries being written to the transaction log as this is used to maintain database integrity.
You could put the new table in it's own database with the log set to truncate on checkpoint.

The create SP is used by other processes? How do you stop these processes conficting with each other?

try

begin tran
select * from newtbl where 1 = 0 (tablockx, holdlock)
EXECUTE usp_CreateCrossTabTable @StartDate, @EndDate
EXECUTE usp_DisplayCrossTabTable_ForXML
commit tran

0
 

Author Comment

by:bmccleary
ID: 6976052
Nigel,
Sometimes I wonder where my brain is at... I apologize for the delay.  I did use your example and it worked.  Thanks!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question