Mackin, Christopher
CMackin at quiznos.com
Fri Sep 24 16:21:52 CDT 2004
Unlike Access, the conversion between Numeric and String values needs to be done explicitly in T-SQL. Use this: SELECT 'abc' + CAST(lngCompID AS VarChar(100))........... Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Joseph O'Connell Sent: Friday, September 24, 2004 3:04 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Problem concatening a string and a numeric A field in a table contains integer values. How do I create a SQL statement that will prefix the values with a string? For example, if the field values are 1 2 3 I wish to return abc1 abc2 abc3 "SELECT 'abc' + lngCompID AS ModifiedValue FROM dbo.tblCompany" generates an error message: "Syntax error converting the varchar value 'abc' to a column of data type int" "SELECT 'abc' + Cstr(lngCompID) AS ModifiedValue FROM dbo.tblCompany" generates an error message: "'Cstr' is not a recognized function name" Joe O'Connell _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com