| 
	
 | 
 Posted by Hugo Kornelis on 02/15/06 00:26 
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] 
 |