Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

CASE Statement to return Original Value

$
0
0

Hi, 

I have a variable 'County' which has a lot of blank data. What I am doing is creating a CASE statement to fill in the blank variables and to UPDATE the existing 'County' variable/

example:

UPDATE [DTR].[dbo].[CUST]
SET County = 

case when 'Town' = 'Bristol' then 'South West'

case when 'Town' = 'Crewe' then 'Cheshire'

ETC

What I want my CASE statement to do is update the blanks based off my logic but return theoriginal values already held within the 'County' variable as the populated output in this variable, are correct

example: case when 'Town' = 'Bristol' then 'South West'

case when 'Town' = 'Crewe' then 'Cheshire'

then 'County' variable

Anyone able to confirm how to do this please? 


Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>