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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Making insert and geting Err on "ON"

Author  Topic 

statix
Starting Member

12 Posts

Posted - 2013-02-12 : 10:41:58
what's wrong in my query?

INSERT INTO CC
(county_id, city_id)
SELECT DISTINCT x1.county_id, x2.city_id
FROM 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_id
FROM 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
Go to Top of Page

statix
Starting Member

12 Posts

Posted - 2013-02-12 : 11:28:52
thanks worked like a charm!
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-02-12 : 12:19:19
Great! glad it helped.
Go to Top of Page
   

- Advertisement -