Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2006, 10:10 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help: Move data with store proc

I need to create a stored procedure to move data from a table to an history table(same table def). After the data is moved I need to delete it from the first table. I have to ensure that the data is present in the archive prior to deletion of the data in the first table. All this will be happening 24x7 so impacting DB performance is a factor. Basically looking for the most efficient solution.

thanks!

Gunny
 
Old July 27th, 2006, 11:58 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

you can put everything in a transaction so if one of them fails, you can roll everything back and be in a safe position

Regards
Ganesh
http://ganeshprof.blogspot.com
 
Old July 27th, 2006, 02:55 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I basically agree with Ganesh but would like to point out some things. If the sizes of the chunks of data you choose are too large your code will increase its likelyhood in failing in the event the data is changed while your moving it. If you select too small of a chunk of data the process will take a long time, you have to choose a balanced amount depending on your servers workload and the volume of data your dealing with.

 
Old July 28th, 2006, 12:10 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

well you may be right in one aspect..but the thing Gunny is going to do is a simple task which can be accomplished by two direct statements

Begin Transaction
INSERT <ColNames> INTO Tab2
SELECT <ColNames> FROM Tab1
WHERE <Condition>

DELETE Tab1 WHERE <Condition>
Commit Transaction

Regards
Ganesh
http://ganeshprof.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Same Store Proc run 100x slower in identical sql-s jphan5024 SQL Server 2000 0 May 13th, 2008 04:15 PM
Using VBA Code to Move Data Nanette Access VBA 1 November 3rd, 2006 04:16 PM
Best way to move data from 2000 to 2005 JimReid SQL Server 2005 1 May 19th, 2006 05:23 PM
Move Data from oracle10g to oracle8i mohammed_aid Oracle 0 December 11th, 2005 02:23 PM
store proc use in report services of sql server shivani16 ADO.NET 3 June 22nd, 2004 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.