DECLARE @CountryId AS int
DECLARE @Name AS varchar(50)
DECLARE cur CURSOR FOR SELECT c.CountryId, ci.[Name]
FROM City ci
INNER JOIN HotelCountry hc
ON ci.CountryId = hc.country_id
INNER JOIN Country c
ON hc.country_name = c.[Name]
OPEN cur
FETCH NEXT FROM cur INTO @CountryId, @Name
WHILE @@FETCH_STATUS = 0
BEGIN
-- Do what ever you want.
UPDATE City
SET CountryId = @CountryId
WHERE [Name] = @Name
-- Next.
FETCH NEXT FROM cur INTO @CountryId, @Name
END
CLOSE cur
DEALLOCATE cur
Saturday, July 11, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment