Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 27th, 2006, 10:10 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old July 27th, 2006, 11:58 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
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
Reply With Quote
  #3 (permalink)  
Old July 27th, 2006, 02:55 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: Orange County, CA, USA.
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.

Reply With Quote
  #4 (permalink)  
Old July 28th, 2006, 12:10 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03: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 01:23 PM
store proc use in report services of sql server shivani16 ADO.NET 3 June 22nd, 2004 11:17 AM



All times are GMT -4. The time now is 06:18 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.