﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Corey Bunch / Article Discussions / Article Discussions by Author  / Geocoding with SQL Server 2005 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 17:40:20 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>[quote][b]Allen McGuire (6/26/2008)[/b][hr]I personally would not use this method to do what you are trying to do.  If you have a web server that can run ASP, I would simply make a database call to get the customers and their address data, then call the following function with as much or little address information as you wish:Function GetGoogleCoordsCSV(Query)	GoogleMapKey = "your Google key"		url = "http://maps.google.com/maps/geo?output=csv&amp;key=" &amp; GoogleMapKey &amp; "&amp;q=" &amp; Replace(Query,"#","")	set csvhttp = Server.CreateObject("Msxml2.ServerXMLHTTP")  	csvhttp.open "GET", url, false 	csvhttp.send ""	csvResult = Split(csvhttp.responseText, ",")    ' The first number is the status code,     ' the second is the accuracy,     ' the third is the latitude,     ' the fourth one is the longitude.    ' 0 	Unknown location.    ' 1 	Country level accuracy.    ' 2 	Region (state, province, prefecture, etc.) level accuracy.    ' 3 	Sub-region (county, municipality, etc.) level accuracy.    ' 4 	Town (city, village) level accuracy.    ' 5 	Post code (zip code) level accuracy.    ' 6 	Street level accuracy.    ' 7 	Intersection level accuracy.    ' 8 	Address level accuracy.    Precision = csvResult(1)	Longitude = csvResult(3)	Latitude = csvResult(2)End FunctionThen just run an update statement in the ASP to update the customer coordinates.  If you need more information let me know.  Here is the code for the main ASP page:&amp;lt;%strSQL = "SELECT CustomerID, Address1, City, State, Zip FROM Customer"Set oRs = oConn.Execute(strSQL)Do While Not oRs.EOF        CustomerID = orS("CustomerID")        Address1 = oRs("Address1")	City = oRs("City")	State = oRs("State")	Zip = oRs("Zip")	If Address1 &amp;lt;&amp;gt; "" and City &amp;lt;&amp;gt; "" Then ' no sense in geocoding blank address	    Call GetGoogleCoordsCSV(Replace(Address1,"#","") &amp; " " &amp; City &amp; " " &amp; State)        oConn.Execute("UPDATE Customer SET Latitude = '" &amp; Latitude &amp; "', Longitude = '" &amp; Longitude &amp; "', Modified = GETDATE() WHERE CustomerID = " &amp; CustomerID &amp; "")	End If	oRs.MoveNextLoop%&amp;gt;[/quote]thanks for the code! works great! is it possible to do the same in aspx, c#? i'm not really familiar with .net.</description><pubDate>Fri, 30 Dec 2011 06:42:20 GMT</pubDate><dc:creator>proleget</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Hi,How can I store the Latitude and Longitude results in a table, the stored procedure returns any value ?Thanks</description><pubDate>Tue, 12 May 2009 03:25:46 GMT</pubDate><dc:creator>juanvi</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Thank you so much for the help. I'll give it a try.</description><pubDate>Sun, 18 Jan 2009 11:09:53 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>If you go to File, New Project, then you should have various options, including database projects, business intelligence projects, etc.  If you do not see these options, stick in the SQL Server 2008 CD, and install Workstation Components, and make sure Business Intelligence Development Studio (BIDS) or whatever they're calling it now is installed.  This will install the appropriate project types.  Then Start, All Programs, Microsoft SQL Server, BIDS.</description><pubDate>Sun, 18 Jan 2009 10:52:54 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Yes, I have tried but when I open a new solution there are no templates except "blank solution". I was hoping someone has created this stored procedure with visual studio 2008 and knew what to do next.Thank you for any help.</description><pubDate>Sat, 17 Jan 2009 14:00:39 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Have you tried the steps in the article?  I haven't tried with 2008 but I cannot imagine it would be much different.</description><pubDate>Sat, 17 Jan 2009 10:54:01 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Does anyone know how to add this stored procedure using visual studio 2008?any help would be appreciated.</description><pubDate>Sat, 17 Jan 2009 10:11:42 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Can I compile this using visual studio 2008 express? If not does any one know what I can use if I don't have visual studio 2005?</description><pubDate>Sun, 11 Jan 2009 20:49:42 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Thank you for the help. I only have vwd 2008 and it wont work by following the article. I guess I'll have to purchase visual studio to get the stored procedure in my database unless someone knows of another way.Thank you for the help.</description><pubDate>Sun, 11 Jan 2009 10:38:55 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Mikek - unfortunately it is not as simple as copy/paste.  If you have visual studio you can just follow the directions in the article, and check out everyone's feedback on the forums, as others have found better ways to do things.  If you do not have visual studio, you can do a command line compile if you wish, but I think you will still need some parts of visual studio or .net to at least compile the c#.After it's compiled is when you load it into sql server - which you can do with sql server management studio.</description><pubDate>Sun, 28 Dec 2008 18:25:16 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>How do I make this work for me? Do I just paste the code as a stored procedure in my sql 2005 database?Thank you for any help in advance.Mikek</description><pubDate>Sun, 28 Dec 2008 11:53:41 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Can I do this in sql server management express instead of visual studio?</description><pubDate>Sun, 12 Oct 2008 09:07:18 GMT</pubDate><dc:creator>mklausmeyer3</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Hello Thanks for your mailI did have an address and found a workaround, namely calling my procedure from another one. I can now create Google maps based on the latitude/longitud data. I have created a reporting service report and it works fine from visual studio, But when I deploy it to my report server and call it from a browser I get an error from Google saying "Bad RequestYour client has issued a malformed or illegal request. "Have tried calling the google static function from reporting services? How can I avoid this error?</description><pubDate>Fri, 01 Aug 2008 06:00:46 GMT</pubDate><dc:creator>lima_2001</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Hopefully I understood  you correctly - if not let me know.  Maybe even post the code of whatever isn't working.Allenhttp://www.madtownlounge.comLocate Live Music</description><pubDate>Thu, 31 Jul 2008 19:21:14 GMT</pubDate><dc:creator>Allen McGuire</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>If you don't have an address, don't send anything - not even a question mark.  Google's API will return lat/long still.  I've done it many times with just city/state pairs.</description><pubDate>Thu, 31 Jul 2008 19:19:57 GMT</pubDate><dc:creator>Allen McGuire</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Hello I also enjoyed using this article and all works except that I get an error in Visual studio when I try to use the store procedure with a dynamic addressm(it just refuses to let me use the ?-mark and says I have a syntax error)this is the sentence i useEXEC	[dbo].[SPGeocode]		@Address = ?,		@City = NULL,		@State = NULL,		@appid = N'MyyahooId'I am trying to get the latitud/longitude for a number of addresses.  I call the procedure from within a FOR each LOOP. If I use a given address it works. I also worte a standard procedure that takes a text and inserts a record. It also works with my ?-mark.What do I need to do to be able to use a dynamic input for the Address parameter?regards lima</description><pubDate>Thu, 31 Jul 2008 18:57:29 GMT</pubDate><dc:creator>lima_2001</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Hmm going to try all reccomendations and see what I can understand / get working.To be honest I'm used to doing fairly simple stuff with SQL2000 and vb.net so this is all a bit scary atm and my first venture into SQL2005I cant thank you guys enough for helping though, I will let you know how I get on...Cheers,Nik</description><pubDate>Thu, 26 Jun 2008 09:24:10 GMT</pubDate><dc:creator>nik.hall</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I personally would not use this method to do what you are trying to do.  If you have a web server that can run ASP, I would simply make a database call to get the customers and their address data, then call the following function with as much or little address information as you wish:Function GetGoogleCoordsCSV(Query)	GoogleMapKey = "your Google key"		url = "http://maps.google.com/maps/geo?output=csv&amp;key=" &amp; GoogleMapKey &amp; "&amp;q=" &amp; Replace(Query,"#","")	set csvhttp = Server.CreateObject("Msxml2.ServerXMLHTTP")  	csvhttp.open "GET", url, false 	csvhttp.send ""	csvResult = Split(csvhttp.responseText, ",")    ' The first number is the status code,     ' the second is the accuracy,     ' the third is the latitude,     ' the fourth one is the longitude.    ' 0 	Unknown location.    ' 1 	Country level accuracy.    ' 2 	Region (state, province, prefecture, etc.) level accuracy.    ' 3 	Sub-region (county, municipality, etc.) level accuracy.    ' 4 	Town (city, village) level accuracy.    ' 5 	Post code (zip code) level accuracy.    ' 6 	Street level accuracy.    ' 7 	Intersection level accuracy.    ' 8 	Address level accuracy.    Precision = csvResult(1)	Longitude = csvResult(3)	Latitude = csvResult(2)End FunctionThen just run an update statement in the ASP to update the customer coordinates.  If you need more information let me know.  Here is the code for the main ASP page:&amp;lt;%strSQL = "SELECT CustomerID, Address1, City, State, Zip FROM Customer"Set oRs = oConn.Execute(strSQL)Do While Not oRs.EOF        CustomerID = orS("CustomerID")        Address1 = oRs("Address1")	City = oRs("City")	State = oRs("State")	Zip = oRs("Zip")	If Address1 &amp;lt;&amp;gt; "" and City &amp;lt;&amp;gt; "" Then ' no sense in geocoding blank address	    Call GetGoogleCoordsCSV(Replace(Address1,"#","") &amp; " " &amp; City &amp; " " &amp; State)        oConn.Execute("UPDATE Customer SET Latitude = '" &amp; Latitude &amp; "', Longitude = '" &amp; Longitude &amp; "', Modified = GETDATE() WHERE CustomerID = " &amp; CustomerID &amp; "")	End If	oRs.MoveNextLoop%&amp;gt;</description><pubDate>Thu, 26 Jun 2008 09:13:42 GMT</pubDate><dc:creator>Allen McGuire</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>You have mostly 2 options. * Use a couple cursors (lookup how to use cursors in BOL) to iterate your source table and the return from the SP (you can dump the output of the SP into a temp table using an INSERT statement or you can use OpenRowSet)* Use the TVF I posted on 2006/05/10 in page 3. And see my 2007/02/09 post (same page) on how to use it for multiple hits.</description><pubDate>Thu, 26 Jun 2008 08:53:03 GMT</pubDate><dc:creator>zootie</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Guys, This is all a bit advanced for me but I have gotten to the stage where I have SPGecode sproc working which is brill but...What I would ideally like to do is use it somehow to update a table of customer addresses with the lat/long returned from the sproc.  Could someone be kind and put me out of my misery as to how I might be able to do this?I am thinking another sproc which updates the table with the lat/long returned from the SPGeocode on a row by row basis????Any help would really be appreciated.Nik</description><pubDate>Thu, 26 Jun 2008 03:12:57 GMT</pubDate><dc:creator>nik.hall</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Both Yahoo and Google return "precision" values, so it's all about how you handle the returned data.The big difference for me in choosing my provider is that with Google you get like 50,000 hits per day; with Yahoo! last I heard was more like 5,000.  I just use Yahoo! as a backup in case Google doesn't return me any data.</description><pubDate>Wed, 20 Feb 2008 10:49:56 GMT</pubDate><dc:creator>Allen McGuire</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I haven't run data using both providers. My experiences with Google are from semi-manually running maps in Google Maps and Google Earth. Yahoo seems more forgiving and to try harder to return an approximate geocode. Also, since you get a "scope" out of the Yahoo API, it would return an area geocode (zip or city) when Google would just fail. The age of the data might also be a factor: It was funny getting Google maps with properties that were over hills or parking lots. The geocode (Yahoo and/or Google's) would be accurate, but the map would be incorrect because the road data and satellite imagery hadn't been updated.</description><pubDate>Wed, 20 Feb 2008 10:35:03 GMT</pubDate><dc:creator>zootie</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I've just used it for testing purposes to get a feeling with as well CLR as geocoding.I didn't compare the various providers. Maybe others did or are using it in a production environment.</description><pubDate>Mon, 11 Feb 2008 07:41:38 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I've been geocoding assets using a variety of engines and I've been surprised that yahoo's engine has been more accurate than Google's geocoding service. Has anyone else noticed this?</description><pubDate>Fri, 08 Feb 2008 16:03:46 GMT</pubDate><dc:creator>Sam Stange</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Here's what you need for google maps:using System;using System.IO;using System.Net;using System.Xml;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using Microsoft.SqlServer.Server;using System.Globalization;namespace Geocoders{    public partial class GoogleGeocoder    {        [Microsoft.SqlServer.Server.SqlProcedure]        public static void GetGoogleGeocode(string address, out double latitude, out double longitude, out double range)        {            Stream stream = null;            XmlDocument doc;            HttpWebRequest req;            string text = "";            try            {                req = (HttpWebRequest)WebRequest.Create("http://maps.google.com/maps?output=kml&amp;q=" + address);                HttpWebResponse response = (HttpWebResponse)req.GetResponse();                stream = response.GetResponseStream();                StreamReader sr = new StreamReader(stream);                text = sr.ReadToEnd();                sr.Close();                if (String.IsNullOrEmpty(text))                {                    latitude = 0;                    longitude = 0;                    range = 0;                }                else                {                    doc = new XmlDocument();                    doc.LoadXml(text);                    XmlNodeList longitudes = doc.GetElementsByTagName("longitude");                    XmlNodeList latitudes = doc.GetElementsByTagName("latitude");                    XmlNodeList ranges = doc.GetElementsByTagName("range");                    NumberFormatInfo NFormat = new NumberFormatInfo();                    NumberFormatInfo NFormatInt = new NumberFormatInfo();                    NFormat.NumberDecimalSeparator = ".";                    double.TryParse(latitudes[0].InnerText, NumberStyles.Float, NFormat, out latitude);                    double.TryParse(longitudes[0].InnerText, NumberStyles.Float, NFormat, out longitude);                    double.TryParse(ranges[0].InnerText, NumberStyles.Float, NFormat, out range);                }            }            catch            {                text = null;                latitude = 0;                longitude = 0;                range = 0;            }            finally            {            }        }    }}</description><pubDate>Wed, 12 Dec 2007 13:02:06 GMT</pubDate><dc:creator>Sam Stange</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Great post - I was looking for this very thing.  Question: how can I do the same using Google's API?  Since Yahoo only allows 5K and Google allows 50K/day, I would like to see the same sort of example but using Google's API.  I'm trying to find out how to do it myself, but I'm not real handy with C# just yet.</description><pubDate>Tue, 11 Sep 2007 15:18:00 GMT</pubDate><dc:creator>Allen McGuire</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I'm also getting the message that the stored procedure ran successfully but I'm not getting any results.  Could a firewall and/or proxy restrict this from truly running?Update:It was a proxy causing the problem.  Here is a tweak to Corey's code that I found to work for my company's authenticated proxy.  I found that trying to use the webproxy.getdefaultproxy() didn't work because this seems to run as a service, possibly, therefore tossing out any user credentials. Hopefully this helps someone out.using System;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using Microsoft.SqlServer.Server;using System.Net;using System.Xml;using System.Xml.XPath;using System.Text;public partial class StoredProcedures{    [Microsoft.SqlServer.Server.SqlProcedure]    public static void SPGeocode(string Address, string City, string State, string appid)    {        //Declare string for URL        //string URL;        WebRequest request;        try        {            //Replace the spaces in your Address with the plus sign to build the URL needed for Yahoo            Address = Address.Replace(" ", "+");            //Build the URL            request = WebRequest.Create("http://api.local.yahoo.com/MapsService/V1/geocode?appid=" + appid + "&amp;street=" + Address + "&amp;city=" + City + "&amp;state=" + State);            request.Proxy = new WebProxy("ww.xx.yy.zz", 8080);            request.Proxy.Credentials = new System.Net.NetworkCredential("username", "password", "domain");            request.Credentials = System.Net.CredentialCache.DefaultCredentials;            // Create the record and specify the metadata for the columns.            SqlDataRecord record = new SqlDataRecord(                new SqlMetaData("Latitude", System.Data.SqlDbType.VarChar, 100),                new SqlMetaData("Longitude", System.Data.SqlDbType.VarChar, 100),                new SqlMetaData("GeoCodedAddress", System.Data.SqlDbType.VarChar, 100),                new SqlMetaData("GeoCodedCity", System.Data.SqlDbType.VarChar, 100),                new SqlMetaData("GeoCodedState", System.Data.SqlDbType.VarChar, 2),                new SqlMetaData("GeoCodedZip", System.Data.SqlDbType.VarChar, 10),                new SqlMetaData("GeoCodedCountry", System.Data.SqlDbType.VarChar, 10),                new SqlMetaData("Precision", System.Data.SqlDbType.VarChar, 100),                new SqlMetaData("Warning", System.Data.SqlDbType.VarChar, 100));            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)            {                DataSet ds = new DataSet();                ds.ReadXml(response.GetResponseStream());                //If the response included an error, then the array length is different, 0-7                if (ds.Tables[0].Rows[0].ItemArray.Length.Equals(9))                {                    record.SetString(0, ds.Tables[0].Rows[0].ItemArray[0].ToString());                    record.SetString(1, ds.Tables[0].Rows[0].ItemArray[1].ToString());                    record.SetString(2, ds.Tables[0].Rows[0].ItemArray[2].ToString());                    record.SetString(3, ds.Tables[0].Rows[0].ItemArray[3].ToString());                    record.SetString(4, ds.Tables[0].Rows[0].ItemArray[4].ToString());                    record.SetString(5, ds.Tables[0].Rows[0].ItemArray[5].ToString());                    record.SetString(6, ds.Tables[0].Rows[0].ItemArray[6].ToString());                    record.SetString(7, ds.Tables[0].Rows[0].ItemArray[7].ToString());                    record.SetString(8, ds.Tables[0].Rows[0].ItemArray[8].ToString());                }                else                //If the response did not include an error, then the array length is 0-6                {                    record.SetString(0, ds.Tables[0].Rows[0].ItemArray[0].ToString());                    record.SetString(1, ds.Tables[0].Rows[0].ItemArray[1].ToString());                    record.SetString(2, ds.Tables[0].Rows[0].ItemArray[2].ToString());                    record.SetString(3, ds.Tables[0].Rows[0].ItemArray[3].ToString());                    record.SetString(4, ds.Tables[0].Rows[0].ItemArray[4].ToString());                    record.SetString(5, ds.Tables[0].Rows[0].ItemArray[5].ToString());                    record.SetString(6, ds.Tables[0].Rows[0].ItemArray[6].ToString());                    record.SetString(7, "Precision Good");                    record.SetString(8, "No Error");                }            }            // Mark the begining of the result-set.            SqlContext.Pipe.SendResultsStart(record);            SqlContext.Pipe.SendResultsRow(record);            // Mark the end of the result-set.            SqlContext.Pipe.SendResultsEnd();        }        catch (Exception ex)        {            //Catch any errors here            throw new Exception("mynewexception", ex);        }    }};</description><pubDate>Thu, 19 Apr 2007 11:50:00 GMT</pubDate><dc:creator>Crasz</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I probably have made small changes since then. But a quick tests, and the TVF function seems to be working ok. The SP also seems to be working, however, the precision is always null. I did modify the SP a bit, so there might be something in the logic that broke since then... I'll try and sit down later, and go over the code, see differences between the SP and TVF, and the original article code...</description><pubDate>Wed, 21 Feb 2007 12:32:00 GMT</pubDate><dc:creator>zootie</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>That's odd - I haven't checked in with Yahoo Maps API lately, so I'm wondering if they changed any of their web service calls?  Is the tutorial working out there for others?  I'll give it a try from scratch on my new machine &amp; check back in &amp; see if mine is still working.</description><pubDate>Wed, 21 Feb 2007 11:37:00 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I have followed the tutorial and everything went according to plan but when i execute the SP, it says Command Completed Successfully but I dont get any rows returned.  I'm using the same test data as in the tutorial and I've tried other addresses too.Any ideas whats wrong or where I should start troubleshooting?Thanks</description><pubDate>Wed, 21 Feb 2007 09:04:00 GMT</pubDate><dc:creator>Matt Rushton</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;I also agree that making a CLR call from within a Trigger is a bit risky (your DBA probably won’t appreciate you doing this while he is away). With this assembly, I've encountered a sporadic error, presumably due to connectivity issues, that locks the assembly, and forces you to have to reinstall it. I haven't been able to reproduce it in a controlled environment to try and handle it within the assembly.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Msg 6260, Level 16, State 1, Line 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;An error occurred while getting new row from user defined Table Valued Function : &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;System.InvalidOperationException: Handle is not initialized.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;System.InvalidOperationException: &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;   &lt;/SPAN&gt;at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;The statement has been terminated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;That aside, to handle multiple matches by averaging the geocodes, using the TSV function above, the code would look like&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;select   addr.AddressGuid,  gc.*&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;into #tmpAddressGeocodefrom   dbo.AddressTbl addr with (NoLock)  cross apply dbo.fncGeocodeByAddress (     addr.StreetAddress1 + coalesce (' ' + StreetAddress2,''),     addr.CityName,     addr.State,     addr.Zip,     'YahooDemo' ) gc&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;update addr set &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;LatitudeRad = LatAvg&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;, LongitudeRad = LongAvg&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;, LatestGeocodeAttemptDate = getutcdate()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;, GeocodePrecision = Prec&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;, GeocodeMultiCnt = GeoCnt&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;from (&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;select &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;AddressGuid, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;LatMin = Min (LatitudeRad),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;LongMin = Min (LongitudeRad),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;LatMax = Max (LatitudeRad),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;LongMax = Max (LongitudeRad),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;LatAvg = Avg (LatitudeRad),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;LongAvg = Avg (LongitudeRad),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;Prec = dbo.Concatenate (distinct geos.[Precision] ),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;GeoCnt = count (*)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;from #tmpAddressGeocode geos with (NoLock)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;group by AddressGuid&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;) geos&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;join dbo.AddressTbl addr on addr.AddressGuid = geos.AddressGuid&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;where&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;-- 5 miles or less when multiple points&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;dbo.DistanceGreatArc ( LatMin, LongMin, LatMax, LongMax ) * dbo.EarthRadiusCalc ( 1, null ) &amp;lt;= 10.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;drop table #tmpAddressGeocode&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;I’m storing other information, like when the geocode was obtained, a list of the precision levels, and how many matches were found. I'm also using a couple other CLR functions. dbo.Concatenate is included in the SQL CLR programming samples, and dbo.DistanceGreatArc is used to calculate the distance (there are multiple implementations you can find on the Internet, either as a CLR or SQL function). The check for the radius to be within 5 miles is a bit redundant, and you could omit it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;If you’re geocoding a considerable number of records, you probably want to mange the temp table a bit more, and use a top to limit the number of geocodes you perform on each run (see earlier post).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;</description><pubDate>Fri, 09 Feb 2007 12:37:00 GMT</pubDate><dc:creator>zootie</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>alzdba - This is exactly what we do on our production system.  We have another table where a bit gets set on or off based on business rules, and then a sql job comes &amp; picks up the bits=1 and runs the CLR process.  This is what I would recommend as well.</description><pubDate>Fri, 09 Feb 2007 06:59:00 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>&lt;P&gt;- it would look like bad code ! &lt;img src='images/emotions/crazy.gif' height='20' width='20' border='0' title='Crazy' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt;- keep in mind you have no control over the availability of the counterparty !&lt;img src='images/emotions/doze.gif' height='20' width='20' border='0' title='Doze' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt;- If you put this clr-routine into a trigger, it will execute "in transaction", meaning if the clr-routine fails, your transaction will fail, so your actual insert statement will be rolled back !!!&lt;/P&gt;&lt;P&gt;- You might want to put this in an assynchrone process (e.g. a sqlagent job).   maybe within the insert trigger just feedin the pk into a "trigger"-table    on which your sqlagent job will start from to get all the geo-info    and will report bad info.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 09 Feb 2007 00:16:00 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>I've just found this tutorial today, and it's awesome! I've contacted Corey directly, but I'm also throwing this one out there for anyone that might catch it. My DBA is out of town, and if I wanted to execute the Assembly and immediately stick the lat/lon into a table from within an Insert trigger for a newly created row, what would that look like?</description><pubDate>Thu, 08 Feb 2007 21:19:00 GMT</pubDate><dc:creator>Ken Nelson-405493</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Great addition!  Thanks!</description><pubDate>Thu, 11 May 2006 16:37:00 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>&lt;P&gt;I recoded it as a TVF function. I modified the logic to return multiple matches, and did some code changes.&lt;/P&gt;&lt;P&gt;I used it to geocode 500 addresses, and it found 4 that returned multiple matches (3 of them at the address level). While it doesn't happen often, and the accuracy of the first match is probably good enough for most applications, if you want high accuracy, you should analyze all the matches returned.&lt;/P&gt;&lt;P&gt;Some examples of how to call it (the first 3 return multiple matches)&lt;/P&gt;&lt;P&gt;select * from dbo.fncGeocodeByAddress ( '245 Union Ave', 'Pueblo', 'CO', '81003', 'YahooDemo' )select * from dbo.fncGeocodeByAddress ( '7920 Stone Creek Dr.', 'Chanhassen', 'MN', '55317', 'YahooDemo' )select * from dbo.fncGeocodeByLocation ( 'Springfield', 'YahooDemo' )select * from dbo.fncGeocodeByAddress ( '100 East 42nd Street', 'new york', 'NY', Null, 'YahooDemo' )select * from dbo.fncGeocodeByAddress ( '701 First Street', 'Sunnyvale', 'CA', Null, 'YahooDemo' )&lt;/P&gt;&lt;P&gt;By making it a TVF, it is more flexible, and you can call it in a select using CROSS APPLY&lt;/P&gt;&lt;P&gt;insert tmpAddressGeocode  (       [AddressGuid]      ,[Latitude]      ,[Longitude]      ,[Address]      ,[City]      ,[State]      ,[Zip]      ,[Country]      ,[Precision]      ,[Warning]  )select top 100  addr.AddressGuid,  gc.*from   dbo.AddressTbl addr with (NoLock)  left join tmpAddressGeocode alldone with (NoLock)     on alldone.AddressGuid = addr.AddressGuid  cross apply dbo.fncGeocodeByAddress (     addr.StreetAddress1 + coalesce (' ' + StreetAddress2,''),     addr.CityName,     addr.State,     addr.Zip,     'YahooDemo' ) gcwhere   alldone.AddressGuid is Null&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SQL Installation&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;CREATE FUNCTION [dbo].[fncGeocodeByLocation](@Location nvarchar(4000), @appid nvarchar(100))RETURNS TABLE ( [Latitude] float Null,  [Longitude] float Null,  [Address] nvarchar(80) Null,  [City] nvarchar(35) Null,  [State] nchar(2) Null,  [Zip] nvarchar(10) Null,  [Country] nvarchar(35) Null,  [Precision] nvarchar(10) Null,  [Warning] nvarchar(1024) Null)AS EXTERNAL NAME [YahooGCSQL].[sqlservercentral.Geocoding.YGeocode].[GeocodeByLocation]GO&lt;/P&gt;&lt;P&gt;CREATE FUNCTION [dbo].[fncGeocodeByAddress](  @Address [nvarchar](4000),  @City [nvarchar](4000),  @State [nvarchar](4000),  @Zip [nvarchar](10),  @appid nvarchar(100))RETURNS TABLE ( [Latitude] float Null,  [Longitude] float Null,  [Address] nvarchar(80) Null,  [City] nvarchar(35) Null,  [State] nchar(2) Null,  [Zip] nvarchar(10) Null,  [Country] nvarchar(35) Null,  [Precision] nvarchar(10) Null,  [Warning] nvarchar(1024) Null)AS EXTERNAL NAME [YahooGCSQL].[sqlservercentral.Geocoding.YGeocode].[GeocodeByAddress]GO&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Function Assembly Code&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using System.Web;using System.Xml;using System.Xml.XPath;using System.Text;using Microsoft.SqlServer.Server;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;namespace sqlservercentral.Geocoding{  public sealed class YGeocode  {    /// &amp;lt;summary&amp;gt;    /// Prevent instances by making constructor private    /// &amp;lt;/summary&amp;gt;    private YGeocode()    {    }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;    /// &amp;lt;summary&amp;gt;    /// Query Yahoo Geocode API, and return an enumeration of results. Have to provide City and State or Zip or Location. Data is extracted for SQL by FillRow    /// &amp;lt;/summary&amp;gt;    /// &amp;lt;param name="AppId"&amp;gt;Yahoo application ID&amp;lt;/param&amp;gt;    /// &amp;lt;param name="StreetAddress"&amp;gt;Street Address&amp;lt;/param&amp;gt;    /// &amp;lt;param name="City"&amp;gt;City name&amp;lt;/param&amp;gt;    /// &amp;lt;param name="State"&amp;gt;US State 2 letter abbreviation&amp;lt;/param&amp;gt;    /// &amp;lt;param name="Zip"&amp;gt;Zip Code&amp;lt;/param&amp;gt;    /// &amp;lt;param name="Location"&amp;gt;Free form address/location&amp;lt;/param&amp;gt;    /// &amp;lt;returns&amp;gt;Enumeration of addresses found&amp;lt;/returns&amp;gt;    private static IEnumerable GeocodeStart(SqlString AppId, SqlString StreetAddress, SqlString City, SqlString State, SqlString Zip, SqlString Location)    {      // Based on &lt;/FONT&gt;&lt;A href="http://www.sqlservercentral.com/columnists/cBunch/geocodingwithsqlserver2005.asp"&gt;&lt;FONT face="Courier New" size=1&gt;http://www.sqlservercentral.com/columnists/cBunch/geocodingwithsqlserver2005.asp&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New" size=1&gt;      try      {        // Build the URL        StringBuilder sb = new StringBuilder();        sb.Append(AppId);        if (!StreetAddress.IsNull)        {          sb.Append("&amp;amp;street=");          sb.Append(StreetAddress);        }        if (!City.IsNull)        {          sb.Append("&amp;amp;city=");          sb.Append(City);        }        if (!State.IsNull)        {          sb.Append("&amp;amp;state=");          sb.Append(State);        }        if (!Zip.IsNull)        {          sb.Append("&amp;amp;zip=");          sb.Append(Zip);        }        if (!Location.IsNull)        {          sb.Append("&amp;amp;location=");          sb.Append(Location);        }        // Replace spaces and # with +        // string Address = System.Web.HttpUtility.UrlEncode(StreetAddress);        // It seems that HttpUtility.UrlEncode is not available here (Compact Framework?), so we have to do it "manually"        // If need be, could use the implementation available at &lt;/FONT&gt;&lt;A href="http://www.devx.com/vb2themax/Tip/19352"&gt;&lt;FONT face="Courier New" size=1&gt;http://www.devx.com/vb2themax/Tip/19352&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New" size=1&gt; (just check for the = and &amp;amp; )        sb.Replace('#', '+');        sb.Replace(' ', '+');        // Prepend the API URL        sb.Insert(0, "&lt;/FONT&gt;&lt;A href="http://api.local.yahoo.com/MapsService/V1/geocode?appid"&gt;&lt;FONT face="Courier New" size=1&gt;http://api.local.yahoo.com/MapsService/V1/geocode?appid&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New" size=1&gt;=");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;        String URL = sb.ToString();&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;        // Get the XML response        XmlTextReader xmlread = new XmlTextReader(URL);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;        // Create a Dataset to hold the results        DataSet ds = new DataSet();&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;        // Fill the DS        ds.ReadXml(xmlread);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;        // Return rows of data        return ds.Tables[0].Rows;      }      catch (Exception ex)      {        // Catch any errors here        ;      }      return null;    }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;    [SqlFunction(FillRowMethodName = "FillRow",       TableDefinition="[Latitude] float Null, [Longitude] float Null, [Address] nvarchar(80) Null, [City] nvarchar(35) Null, [State] nchar(2) Null, [Zip] nvarchar(10) Null, [Country] nvarchar(35) Null, [Precision] nvarchar(15) Null, [Warning] nvarchar(1024) Null")]    public static IEnumerable GeocodeByAddress(SqlString StreetAddress, SqlString City, SqlString State, SqlString Zip, SqlString AppId)    {      return GeocodeStart(AppId, StreetAddress, City, State, Zip, null);    }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;    [SqlFunction(FillRowMethodName = "FillRow",      TableDefinition = "[Latitude] float Null, [Longitude] float Null, [Address] nvarchar(80) Null, [City] nvarchar(35) Null, [State] nchar(2) Null, [Zip] nvarchar(10) Null, [Country] nvarchar(35) Null, [Precision] nvarchar(15) Null, [Warning] nvarchar(1024) Null")]    public static IEnumerable GeocodeByLocation(SqlString Location, SqlString AppId)    {      return GeocodeStart(AppId, null, null, null, null, Location);    }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size=1&gt;    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters")]    public static void FillRow(object obj,       out SqlDouble Latitude, out SqlDouble Longitude,      out string Address, out string City, out string State, out string Zip, out string Country,      out string Precision, out string Warning )    {      // XML elements and attributes are case sensitive.       // Access by name to protect against API changes. It is slower, but not so bad compared with the cost of calling an Internet API      DataRow row = (DataRow)obj;      if (!String.IsNullOrEmpty(row["Latitude"].ToString()))        Latitude = Convert.ToDouble(row["Latitude"].ToString());      else        Latitude = SqlDouble.Null;      if (!String.IsNullOrEmpty(row["Longitude"].ToString()))        Longitude = Convert.ToDouble(row["Longitude"].ToString());      else        Longitude = SqlDouble.Null;      Address = (!String.IsNullOrEmpty(row["Address"].ToString())) ? row["Address"].ToString() : null;      City = (!String.IsNullOrEmpty(row["City"].ToString())) ? row["City"].ToString() : null;      State = (!String.IsNullOrEmpty(row["State"].ToString())) ? row["State"].ToString() : null;      Zip = (!String.IsNullOrEmpty(row["Zip"].ToString())) ? row["Zip"].ToString() : null;      Country = (!String.IsNullOrEmpty(row["Country"].ToString())) ? row["Country"].ToString() : null;      // Better way to detect precision/warning columns w/o going back up to the columns collection? w/o resorting to exception trapping? w/o assuming indexes?      // Alternate way = Precision = (row.ItemArray.Length &amp;gt;= 8) &amp;amp;&amp;amp; !String.IsNullOrEmpty(row["precision"].ToString()) ? row["precision"].ToString() : null;      Precision = (row.Table.Columns.Contains("precision")) &amp;amp;&amp;amp; !String.IsNullOrEmpty(row["precision"].ToString()) ? row["precision"].ToString() : null;      Warning = (row.Table.Columns.Contains("warning")) &amp;amp;&amp;amp; !String.IsNullOrEmpty(row["warning"].ToString()) ? row["warning"].ToString() : null;    }  }};&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;</description><pubDate>Wed, 10 May 2006 16:13:00 GMT</pubDate><dc:creator>zootie</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>&lt;P&gt;It works just fine now !!&lt;img src='images/emotions/w00t.gif' height='20' width='20' border='0' title='w00t' align='absmiddle'&gt;&lt;img src='images/emotions/w00t.gif' height='20' width='20' border='0' title='w00t' align='absmiddle'&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Data&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Data.SqlClient&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Data.SqlTypes&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; Microsoft.SqlServer.Server&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Net&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Xml&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Xml.XPath&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Imports&lt;/FONT&gt;&lt;FONT size=2&gt; System.Text&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;P&gt;'Zie http://www.sqlservercentral.com/columnists/cBunch/geocodingwithsqlserver2005_printversion.asp&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Partial&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Class&lt;/FONT&gt;&lt;FONT size=2&gt; StoredProcedures&lt;/P&gt;&lt;P&gt;&amp;lt;Microsoft.SqlServer.Server.SqlProcedure()&amp;gt; _&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Shared&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; SPCLR_Geocode(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; Address &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; City &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; State &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; appid &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Declare string for URL&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; URL &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"_empty_"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Yahoo test appid ""&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Replace the spaces in your Address with the plus sign to build the URL needed for Yahoo&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;Address = Address.Replace(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"+"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Provide webservice and proxy and credentials&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; myWebSvc &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; System.Net.WebClient&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; myWebProxy &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; System.Net.WebProxy(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"xxx.yyy.zzz.aaa"&lt;/FONT&gt;&lt;FONT size=2&gt;, myport)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'use current users credentials&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;myWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials&lt;/P&gt;&lt;P&gt;myWebSvc.Proxy = myWebProxy&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Build the URL&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;URL = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"http://api.local.yahoo.com/MapsService/V1/geocode?appid="&lt;/FONT&gt;&lt;FONT size=2&gt; + appid + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;street="&lt;/FONT&gt;&lt;FONT size=2&gt; + Address + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;city="&lt;/FONT&gt;&lt;FONT size=2&gt; + City + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;state="&lt;/FONT&gt;&lt;FONT size=2&gt; + State&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' http://api.local.yahoo.com/MapsService/V1/geocode?appid=myyahooappid&amp;amp;street=8&amp;amp;city=seattle&amp;amp;state=wa&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' &lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get the XML response&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; xmlread &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; XmlTextReader(myWebSvc.OpenRead(URL))&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' Create the record and specify the metadata for the columns.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; record &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlDataRecord(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Latitude"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 100), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Longitude"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 100), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GeoCodedAddress"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 100), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GeoCodedCity"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 100), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GeoCodedState"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 2), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GeoCodedZip"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 10), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GeoCodedCountry"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 10), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Precision"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 100), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; SqlMetaData(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Warning"&lt;/FONT&gt;&lt;FONT size=2&gt;, System.Data.SqlDbType.VarChar, 100))&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Create a Dataset to hold the results&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; ds &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; DataSet()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Fill the DS&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;ds.ReadXml(xmlread)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' Mark the begining of the result-set.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;SqlContext.Pipe.SendResultsStart(record)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;For&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Each&lt;/FONT&gt;&lt;FONT size=2&gt; Rij &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; DataRow &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;In&lt;/FONT&gt;&lt;FONT size=2&gt; ds.Tables(0).Rows&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; Rij.ItemArray.Length.Equals(9) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;record.SetString(0, Rij.ItemArray(0).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(1, Rij.ItemArray(1).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(2, Rij.ItemArray(2).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(3, Rij.ItemArray(3).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(4, Rij.ItemArray(4).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(5, Rij.ItemArray(5).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(6, Rij.ItemArray(6).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(7, Rij.ItemArray(7).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(8, Rij.ItemArray(8).ToString())&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'If the response did not include an error, then the array length is 0-6&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Else&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;record.SetString(0, Rij.ItemArray(0).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(1, Rij.ItemArray(1).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(2, Rij.ItemArray(2).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(3, Rij.ItemArray(3).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(4, Rij.ItemArray(4).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(5, Rij.ItemArray(5).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(6, Rij.ItemArray(6).ToString())&lt;/P&gt;&lt;P&gt;record.SetString(7, &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Precision Good"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;record.SetString(8, &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"No Error"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;SqlContext.Pipe.SendResultsRow(record)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Next&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;' Mark the end of the result-set.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;SqlContext.Pipe.SendResultsEnd()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Catch&lt;/FONT&gt;&lt;FONT size=2&gt; ex &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; Exception&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Throw&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; Exception(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;.Format(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"AT_Error with url [{0}]"&lt;/FONT&gt;&lt;FONT size=2&gt;, URL.ToString), ex)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;P&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Class&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;Deploy and &lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;P&gt;EXECUTE&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; SPCLR_Geocode &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'8'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'Seattle'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'WA'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'MyYahooAppId'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P&gt;&lt;FONT color=#ff0000 size=2&gt;Thank your for your support !&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Wed, 03 May 2006 08:08:00 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Theoretically.....we'll see.  Give it a try.</description><pubDate>Wed, 03 May 2006 07:54:00 GMT</pubDate><dc:creator>scb</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>&lt;P&gt;Thank you for your time.&lt;/P&gt;&lt;P&gt;It took me a while, but finaly I got the winform app to work ...&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;P&gt;Address = Address.Replace(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"+"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; myWebSvc &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; System.Net.WebClient&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; myWebProxy &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; System.Net.WebProxy(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"xxx.yyy.zzz.aaa"&lt;/FONT&gt;&lt;FONT size=2&gt;, myport)&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'use current users credentials&lt;/FONT&gt;&lt;FONT size=2&gt;myWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentialsmyWebSvc.Proxy = myWebProxy&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Build the URL&lt;/FONT&gt;&lt;FONT size=2&gt;URL = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"http://api.local.yahoo.com/MapsService/V1/geocode?appid="&lt;/FONT&gt;&lt;FONT size=2&gt; + appid + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;street="&lt;/FONT&gt;&lt;FONT size=2&gt; + Address + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;city="&lt;/FONT&gt;&lt;FONT size=2&gt; + City + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;state="&lt;/FONT&gt;&lt;FONT size=2&gt; + State&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'Get the XML response&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; xmlread &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; XmlTextReader(myWebSvc.OpenRead(URL))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Now, can I just port this code into the CLR-proc for sql2005 ? &lt;img src='images/emotions/unsure.gif' height='20' width='20' border='0' title='Unsure' align='absmiddle'&gt;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Wed, 03 May 2006 07:52:00 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: Geocoding with SQL Server 2005</title><link>http://www.sqlservercentral.com/Forums/Topic273409-254-1.aspx</link><description>Check in IE - go to Tools, Options, Connections tab, Lan Settings button..., and see if you have a proxy server specified.  My guess is that you do.  You may need to specify the same proxy server settings for this outgoing request from .NET.  I did a quick search and found these....http://www.thescripts.com/forum/thread425824.htmlhttp://www.codeproject.com/vb/net/web_service_by_proxy.asp?df=100&amp;forumid=16041&amp;exp=0&amp;select=1119964Let us know how it goes.</description><pubDate>Wed, 03 May 2006 06:53:00 GMT</pubDate><dc:creator>scb</dc:creator></item></channel></rss>