Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
richardlaw
Yak Posting Veteran
68 Posts |
Posted - 2010-10-02 : 10:32:01
|
| HiI'd like to take two table columns and merge them with some text to create a new column in a view. I know the following is wrong, but it might help illustrate what I'd like to achieve:select [competitionType] & ": in" [competitionLocation] as competitionInfo from table competitionsThanks for any helpRichardRichard Law |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-02 : 10:34:42
|
select [competitionType] + ': in' + [competitionLocation] as competitionInfo from table competitionsNote this will not work properly if there are null values in the columns.Then you have to use isnull() or coalesce(). No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-02 : 10:35:46
|
And if a column that you want to concatenate is a numeric datatype then you have to convert it to varchar. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
richardlaw
Yak Posting Veteran
68 Posts |
Posted - 2010-10-02 : 10:38:51
|
quote: Originally posted by webfred And if a column that you want to concatenate is a numeric datatype then you have to convert it to varchar. No, you're never too old to Yak'n'Roll if you're too young to die.
Perfect. Many thanksRichard Law |
 |
|
|
|
|
|