Sunday, February 12, 2012

Concatinating two field and insert the result

Hii,
I need to concatinate two field and insert the result into each record. So far I managed to display the concatination but how do I insert it?
use northwind

select city, region,([city]+ +[region]) as uniqe
from customers
where region is not null
The resulting records in Quary
Anchorage AK AnchorageAK
Tsawassen BC TsawassenBC
Vancouver BC VancouverBC
San Francisco CA San FranciscoCA


Try it like this:
UPDATE
Customers
SET
city = city + ' ' + region
WHERE
region IS NOT NULL

No comments:

Post a Comment