Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is there a way to use a case when to update a tabl

Author  Topic 

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-09-17 : 09:39:44
I want to update a field based on ranges that fall between a zip code low and a zip code high. Then I want to be able to update a field in Shipments with a field in Rates/Cost that is in that range the field i want to update in shipments is rate this field is zip rate in rates/cost. Here is the code i'm trying to work with.


UPDATE [Shipments].[rate]
SET [Shipments].[rate] = [Rates/Lb].[zip rate]
FROM [Shipments]
WHERE [Shipments].[Origin Zip trunc] BETWEEN [Rates/Lb].[Origin Zip Low]
AND [Rates/Cost)].[Origin Zip High]
AND [Shipments].[Origin Zip trunc] BETWEEN [Rates/Lb].[Dest Zip Low]
AND [Rates/Cost].[Dest Zip High]

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-17 : 11:47:12
didnt understand what problem you're facing. can you explain?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2010-09-17 : 11:48:04
need some DDL and sample data. Follow the How to Ask link and it will show you how to provide the information we need to help.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -