You are here: Re: concatenate two fields in a view? « MsSQL Server « IT news, forums, messages
Re: concatenate two fields in a view?

Posted by Rico on 02/15/06 00:43

Excellent! Thanks Hugo!

"Hugo Kornelis" <hugo@perFact.REMOVETHIS.info.INVALID> wrote in message
news:n5m4v15fumsgroq2cosnr48c4636bdp0u9@4ax.com...
> On Tue, 14 Feb 2006 20:01:57 GMT, "Rico" <r c o l l e n s @ h e m m i n
> g w a y . c o mREMOVE THIS PART IN CAPS> wrote:
>
>>Hello,
>>
>>I'm wondering if there is a way to concatenate two fields or a field and a
>>string value in a single field in a view?
>>
>>Where in Access I might write;
>>
>> [field1] & " (m3)" as TotalVolume
>>
>>is there a way to do this in an SQL Server View?
>>
>>Thanks!
>>
>
> Hi Rico,
>
> SQL Server uses the ANSI standard "+" operator to concatenate strings,
> and the ANSI-standard single quotes to delimit string constants:
>
> field1 + ' (m3)' AS TotalVolume
>
> (Assuming field1 is char or varchar type - if it's numeric, the above
> will result in an error; you'll have to force the correct conversion:
>
> CAST(field1 AS varchar(10)) + ' (m3)' AS TotalVolume
>
> --
> Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация