![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Tue, Dec 2 2008 4:39 PM | Permanent Link |
Dale Derix | I'm sure this is an embarrassingly simple question, but I'm stuck.
I want to create a computed field that is simply two other fields, for instance to create a computed field called FullName that is made of of FirstName + LastName. I'm trying to enter this into the "Computation" window in the ElevateDB Manager with no success. How to I do this? PART II Also, how do I make sure it still returns either the first name or the last name even of one of them is NULL? Thanks Dale |
Tue, Dec 2 2008 5:38 PM | Permanent Link |
Fernando Dias ![]() | Dale,
> I want to create a computed field that is simply two other fields, ALTER TABLE <YourTableName> ADD COLUMN FullName VARCHAR(80) COMPUTED ALWAYS AS TRIM(BOTH ' ' FROM COALESCE(FirstName,'')+' '+COALESCE(LastName,'')) > I'm trying to enter this into the "Computation" window in the ElevateDB Manager with no > success. Why? Do you get any error message? > Also, how do I make sure it still returns either the first name or the last name even of > one of them is NULL? That's what COALESCE is for. Note however that with this computation expression you will never get a NULL value for the column. If you want it to be NULL when both FirstName and LastName are NULL, then use the following expression instead: IF(FirstName IS NULL AND LastName IS NULL, CAST(NULL AS VARCHAR), TRIM(BOTH ' ' FROM COALESCE(FirstName,'')+' '+COALESCE(LastName,'')) ) -- Fernando Dias [Team Elevate] |
Tue, Dec 2 2008 5:55 PM | Permanent Link |
Dale Derix | Awesome! That did the trick!
Many thanks, Dale |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |