| Author |
Topic |
|
webfort
Starting Member
9 Posts |
Posted - 2006-11-06 : 07:45:13
|
| Hi, Was wondering if any one could help me, I'm looking to get the date from two columns in a database and insert them in to one column, its basically the first and second name with a "." in the middle and the domain address to follow.Is this possible?Thanks |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-11-06 : 07:49:53
|
| Insert TableSelect FirstName + '.' + SecondName + DoMainaddress From TableNameChiraghttp://chirikworld.blogspot.com/ |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-06 : 08:52:26
|
| Or just to be safe for NULLS...Insert TableSelect ISNULL(FirstName + CASE WHEN SecondName IS NULL THEN '@' ELSE '.' END, '') + ISNULL(SecondName + '@', '') + ISNULL(DoMainaddress, '') From TableNamePeter LarssonHelsingborg, Sweden |
 |
|
|
webfort
Starting Member
9 Posts |
Posted - 2006-11-06 : 09:05:33
|
| Hi, thanks for that, is there anyway to get it to insert it in to the corrosponding record?Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-06 : 09:09:47
|
I don't understand you. What do you mean with "is there a way to insert it into the corresponding record"?Do you mean you would like to UPDATE some record with the combined value as posted above?UPDATE mtSET mt.MyColumn = ISNULL(FirstName + CASE WHEN SecondName IS NULL THEN '@' ELSE '.' END, '') + ISNULL(SecondName + '@', '') + ISNULL(DoMainaddress, '')FROM MyTable mtINNER JOIN OtherTable ot ON ot.pk = mt.pk Peter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-06 : 09:16:29
|
How about creating computed column?Alter Table xyz(Add SomeCol as (SNULL(FirstName + CASE WHEN SecondName IS NULL THEN '@' ELSE '.' END, '') + ISNULL(SecondName + '@', '') + ISNULL(DoMainaddress, ''))) Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
webfort
Starting Member
9 Posts |
Posted - 2006-11-06 : 09:19:54
|
| Hi,the post that chiragkhabaria posted works, but when I it inserts it does not insert the record to the correct record, it inserts it at the bottom of the table. So row 1 has for name bob and surname smith, it does not insert the email in the same rowThanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-06 : 09:23:10
|
| Of course not. Read my previous answer about UPDATE!Peter LarssonHelsingborg, Sweden |
 |
|
|
|