sql server procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jitupatil2007
    New Member
    • Mar 2008
    • 6

    sql server procedure

    hi friends, i am new to sql server2005 and i want to create a procedure or cursor
    which would work like, i have two table one having the country codes and another having the dialed digits along with the country codes, the problem is i want to select one countrycode match that code with the records from dialed digits table and extract all the record to a temp table and after that want to calculate the total record and sum of their minutes the data look like this

    country table

    mexico | 52
    guatemala | 502
    India | 91
    pakistan 92
    SriLanka |94

    dialed digits table

    07/23/2008 00:00:04 | 7809787411 | 919911599771 | 1163 | 1163 | 0.755950
    07/23/2008 00:00:20 | 6046858944 | 919868012693 | 205 | 205 | 0.133250
    07/23/2008 00:00:29 | 6048200105 | 911635269141 | 1039 | 1039 | 0.769899
    07/23/2008 00:00:32 | 3032432360 | 50278440297 | 6 | 6 | 0.005250
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    You need to parse the dialed number to get what we call Significant Dialed Digit. You have to read the entire dialed number and do reduce the length one at a time coming from the right until you found a matching on your COUNTRY CODE - AREA CODE table. The reason is, there are countries that has almost similar COUNTRY+AREACOD E but are different country (ie CANADA and US). Then you can direct the result to a table and do whatever you need to.

    -- CK

    Comment

    Working...