Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
INSERT INTO CC (county_id, city_id)SELECT DISTINCT x1.county_id, x2.city_idFROM datazip AS d county AS x2 ON d.county = x2.county_name INNER JOIN city AS x2 ON d.city = x2.city_name
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-02-12 : 10:49:04
The syntax should be something like this:
INSERT INTO CC ( county_id, city_id )SELECT DISTINCT x1.county_id, x2.city_idFROM datazip AS d INNER JOIN county AS x1 ON d.county = x1.county_name INNER JOIN city AS x2 ON d.city = x2.city_name