I have a table of users that have their id and address. I need to populate a 2nd table with their id and coordinates generated from their address.
What I would like is to generate their coordinates and populate the 2nd table if a new user is added or their address is changed.
Currently, my solution is to export the user list with addresses, use texas A&M's Geoservices application, retrieve their coordinates, import the new excel file columns into their appropriate places within the new table.
I'm aware that I could create an application outside of sql that checks these tables on a daily schedule for differences and update appropriately but I'd really like to automate this within sql so the tables are updated real time.
答案 0 :(得分:1)
您可以编写代码(例如在.NET中),并将其作为程序集存储在sql-server数据库中。这称为CLR。然后,您可以以存储过程和函数的形式直接从数据库运行此代码。
您可以在代码中编写存储过程以从第一个表中获取数据,查找并根据需要更新/插入到第二个表中。您可以在喜欢的时候调用此存储过程,与任何其他过程相同。
MSDN介绍了如何执行此操作。
Filesystemhelper是一个执行文件操作的clr示例 - 不是您要查找的代码,而是我正在谈论的内容的一个很好的例证。