INNER JOINanother database table with a table country. Only those records with an existing country will be selected.
Note: you must check the relevance of the respective country in both databases.
SET IDENTITY_INSERT City ON
INSERT INTO City (
[cityid]
,[city]
,[country]
,[state]
,[cityinfo]
,[enabled]
,[countryid]
,[citycode]
,[stateid]
,[latitude]
,[longitude])
SELECT ct.[cityid]
,ct.[city]
,ct.[country]
,ct.[state]
,ct.[cityinfo]
,ct.[enabled]
,ct.[countryid]
,ct.[citycode]
,ct.[stateid]
,ct.[latitude]
,ct.[longitude]
FROM TD.DBo.City ct
INNER JOIN dbo.Country cnt ON cnt.CountryID = ct.CountryID
source
share