I trying to make a sql script that will randomize the city, state, and zip code of a "members" table. I have made a table function that returns a single row with columns "city", "state" and "zip" taken from another database at random (via a view). This ensures that I get a city, state, and zip that actually correlate to each other in the real world.
From there I am trying to do something like this:
update t
set
t.City = citystate.city,
t.State = citystate.state,
t.PostalCode = citystate.zip
from
(select
City,
State,
PostalCode from DATABASE.dbo.Member) t,
DATABASE.dbo.getRandomCityState() citystate
Problem is, this only calls my function once, and puts the same city, state, and zip into every row of the table. Is there some way to call my function once for every row in the table?