MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old October 19th, 2003, 10:40 AM
syruss syruss is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 syruss User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with SQL 2000

I need some help trying to do something in SQL2000. I am an ASP developer and as such, not the DBA I wish I was also.

My problem is this:

I will simplify it by only putting the relevant part. I need to know how to update a field in all records that have a certain status with the calculated value from another column in that record.

Table example:

Amount_requested: 500.00
Amount_approved:
Approval_Status: 'Y'

What I need is a way (either a single query - best choice) or a stored_proc with a cursor maybe that would go through these and set amount_approved = amount_requested on all records where approval_status = 'Y'

There could be 50,000 records that meet this criteria, so I am looking for the fastest possible way. I have done it in a cursor but it is slow at best since I am new to cursors and SQL I am probably doing it the hard way.

Any help would be GREATLY appreciated.


Thanks in advance.

Last edited by syruss : October 19th, 2003 at 11:11 AM.

Reply With Quote
  #2  
Old October 19th, 2003, 11:10 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,331 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 7 h 21 m 33 sec
Reputation Power: 891
put away your money

you just about had it all by yourself
Code:
update yourtable
   set amount_approved = amount_requested
  where approval_status = 'Y' 

there remains the question of why you even have the "amount_approved" column at all, if it's gonna be equal to the amount requested for all these records

if, however, amount_approved can sometimes be different from amount requested, then forget i asked

rudy
http://r937.com/

Reply With Quote
  #3  
Old October 19th, 2003, 11:22 AM
syruss syruss is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 syruss User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Actually just before you replied, I figured it out. I removed that paypal part, but will be glad to honor it if you wish.

The purpose behind this is to make it easier to calculate a lot of other items that go along with this. This was just a small piece of the over table and query.

The reason I asked was because I created the query and it kept failing, so I assumed maybe I was trying to do something backwards. I have been working on this set of about 50 queries for the last 2 days, and my mind is shot. So instead of thinking about it, I kinda gave up for a bit. Then I rethought it and tried again and it worked.

I don't have the originals so not sure why they weren't working, but this one does now and it solved the problem.

It is a fun set of queries to work with as it is related to a play gambling site, and when done needs to be able to work on as many as several million bets a day potentially, so making it fast is important.

The site it is based off of ABSOLUTELY SUCKS. I have the code but the way it works will support about 300 users on the server making 2-10 bets a day is all. The new site will be 100 times that and the old code would just kill the dedicated server.

Thanks for your help, as I am sure I will have more here!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Help with SQL 2000


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway