sql server 2008 query

I'm using SQL server 2008 R2

I have a table called EmployeesTable , it looks like this:

EmployeesTable
This is the script to create this table:

CREATE TABLE [dbo].[EmployeesTable](
	[EmployeeID] [int] NULL,
	[LastName] [varchar](50) NULL,
	[FirstName] [varchar](50) NULL,
	[Address] [varchar](100) NULL,
	[City] [varchar](50) NULL,
	[State] [varchar](50) NULL,
	[ZipCode] [varchar](50) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[EmployeesTable] ([EmployeeID], [LastName], [FirstName], [Address], [City], [State], [ZipCode]) VALUES (1, N'Bugs', N'Bunny', N'1 Legends Way', N'Arlington', N'TX', N'76011')
INSERT [dbo].[EmployeesTable] ([EmployeeID], [LastName], [FirstName], [Address], [City], [State], [ZipCode]) VALUES (2, N'Daffy', N'Duck', N'490 Jamestown Avenue', N'San Francisco', N'CA', N'94124')
INSERT [dbo].[EmployeesTable] ([EmployeeID], [LastName], [FirstName], [Address], [City], [State], [ZipCode]) VALUES (3, N'Marvin', N'Martian', N'1000 Elysian Park Avenue', N'Los Angeles', N'CA', N'90012')

Open in new window


Is there a way to write a query where two additional columns are created where the addresses for each employee is geocoded and the latitude for that address is placed in a column called Lat and the longitude for that address is placed in a column called Long ?

So my query result should look something like this except it would have the lat, long values in these columns.

my desired result set
See what I plan to do is to generate xml from my query result set and then feed that xml to google maps javascript api to plot these addresses on a google map.

If there is a better technique to use , please let me know.
I already know how to create a map with xml data, i'm just having trouble geocoding a table of addresses.
LVL 1
maqskywalkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
I would go with a geography datatype.

http://sqlmag.com/sql-server-2008/simplifying-spatial-data
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.