By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,295 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

sql server procedure

P: 6
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
Sep 19 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
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+AREACODE but are different country (ie CANADA and US). Then you can direct the result to a table and do whatever you need to.

-- CK
Sep 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.