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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-11-22 : 10:02:25
|
| Sergio writes "Dear SQL Gurus,SQL VERSION: 7.0 (sp3)Windows VERSION: 2000 desktop; NT4 (sp5) serverI am an experienced programmer with decent SQL skills (far from DBA level but versed enough to know that writting a optimal stored proc beats haveing to hard code multiple calls to the database). I have run into a situation where I REALLY need your help. I have looked thourghout your site and others and I am vigoroulsy waiving a white flag - reallly. I have have been brought on to do some codeing in a very estbalish company with HORRIBLE operation procedure. There is no table that is more than 95% accurate (most are around 80%) so please bear with me as I try to explain.Here is my scenario: I need to determine a fee based on 1) Flat rate (easy) 2) If no flat rate then fee is determined where it was shipped. Here are my tables (brief info): * Orders (order_nbr int [pk]; part_nbr int), * ShippingDetails (order_nbr int [fk]; company_id int, ship_date datetime; country_ship_to varchar[50] - could be blank), * ShipLocations (partnbr int; country_ship_to varchar[50], Amount money) * Company_Data (company_id int, ..., country varchar [50])Here is my SQL code in my Stored Proc(brief info): Create Table #TempParts (order_nbr int) Insert #TempParts SELECT o.Order_Nbr FROM Orders o INNER JOIN ShippingDetails s ON o.Order_Nbr = s.Order_Nbr WHERE o.part_nbr = @partnbr AND s.Ship_Date Between @date1 AND @date2/* ********* I have a stored proc (Country_Shipped_To [ordernbr, @Country_name output]) that gets the country where the order was shipped to (if the no country in ShippingDetails then gets the default country from Customer_Data) that is called FROM another stored proc (Where_Shipped_Amount [ordernbr, @Amount OUTPUT]. I want to avoid using a cursor that will travers through the temp table in order to get the fee amount.********** */Drop Table #TempPartsI hope this makes sense. Any and all suggestion are greatly appreciated.Sergio" |
|
|
|
|
|