Wrox Programmer Forums
|
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 February 25th, 2005, 08:14 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Automate Records Update

Hi All,

Please help. I am using SQL 2000. Here is an example. I have a table called "Saving." This table has two columns, SSN and AMOUNT. At the midnight of each day, I want SQL 2000 to automatically add 10% to the AMOUNT column.

I am not sure where to star, or what method I should use. Do I write a stored procedure and then schedule a task/job? What do I do? Please help.

Thank you.

Leon

 
Old February 26th, 2005, 01:58 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

If you will like to always update the amount column everyday

Use
Code:
UPDATE saving
SET amount = amount * 1.1
but I will also caution and make sure that this is what you really want to do every time, if not make sure you add a where clause. It might be you only what to update records that have changed.

Code:
UPDATE saving
SET amount = amount * 1.1
WHERE (SSN= '999999999')
let me know if you to only change only columns that have changed values.

Jaime E. Maccou
 
Old February 26th, 2005, 02:07 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

sorry i forgot something. to schedule it create a stored procedure and schedule it in a job


 If you will like to always update the amount column everyday

Use
create procedure usp_updateAmount
as
UPDATE saving
SET amount = amount * 1.1



but I will also caution and make sure that this is what you really want to do every time, if not make sure you add a where clause. It might be you only what to update records that have changed.

create procedure usp_updateAmount
as
UPDATE saving
SET amount = amount * 1.1
WHERE (SSN= '999999999')


let me know if you to only change only columns that have changed values.

Jaime E. Maccou


Jaime E. Maccou
 
Old February 28th, 2005, 05:21 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jaime,

Thank you very much for your help! :-) I know a little bit about writing stored procedure. I just wasn't sure if writing a stored procedure, and then schedule it to run is the best AND only method to do what I wanted to do. In other words, is this normally the method programmers would use? I am pretty new to the web-database related world. I am still trying to explore what I can and can't do, and the best method to do it.

Thanks again.

Leon






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Records bspeck Dreamweaver (all versions) 5 October 5th, 2004 03:05 PM
update multiple records mateenmohd Classic ASP Basics 4 June 28th, 2004 03:38 AM
UPDATE RECORDS!!! a_pathak BOOK: Beginning ASP 3.0 1 March 3rd, 2004 04:00 AM
SQL update records topshed Classic ASP Components 5 September 9th, 2003 09:48 AM
Help! Cannot update records mcalder Classic ASP Databases 6 August 14th, 2003 01:54 PM





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