Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Table Locks and Transaction Log Disabling

Posted on 2002-04-02
2
Medium Priority
?
201 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 200 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

705 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