something like:
update table set
add1 = case
when add1 is not NULL then add1
else substring(address, 1, 10) -- do whatever splitting of first line here
end,
add2 = case
when add1 is not null then substring(address, 1, 10) -- first line
else substring(address, 11, 20) -- second line of address
end,
add3 = case
when add1 is not null then substring(address, 11, 20) -- second line
else substring(address, 21, 30) -- third line
end
where address = @address
Something like that except you wouldn't use substring, you would use another function to split it apart. I don't know what your data is like so I can't suggest one.
Brian
|