Saturday, February 25, 2012

Copy a column content in another one only if empty

for MS SQL 2000
table [Users] :
[id_Users] [int] NOT NULL ,
[Name] [varchar] (25) NOT NULL,
[Alias] [varchar] (25) NULL
how can I copy the content of [Name] into the column [Alias] only if [Alias] is Empty ?
thank you--I ve consider null value also in this code.
update Users
set Alias=Name where Alias is null or ltrim(rtrim(Alias))=''|||wonderfull !

it works :-)

thanks a lot

No comments:

Post a Comment