Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Table Locks and Transaction Log Disabling

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
bmccleary
Asked:
bmccleary
1 Solution
 
nigelrivettCommented:
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
 
bmcclearyAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now