Solved

Table Locks and Transaction Log Disabling

Posted on 2002-04-02
2
189 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now