December 30, 2008 at 7:49 am
I am using SQL Server2005
SELECT FIELD1+ ' : ' + FIELD2 as CONCATFIELD
FROM MYFILE
generates the error Conversion failed when converting the varchar value ' : ' to data type int.
How can i resolve this ?
December 30, 2008 at 8:08 am
At least one of your fielsd is an integer datatype. T-SQL won't do implicit type conversion
December 30, 2008 at 8:12 am
That is correct. FIELD1 is an integer field.
I want to concatenate an integer field and a varcharfield. how do i do this ?
December 30, 2008 at 8:13 am
OK i find it myself
STR(FIELD1) does the job
December 30, 2008 at 8:14 am
Look up CAST() and Convert() in BOL - that should give you a start.
HTH
Andrew
December 30, 2008 at 8:21 am
Thanks !
December 30, 2008 at 8:22 am
pvc (12/30/2008)
OK i find it myselfSTR(FIELD1) does the job
STR() without any length argument gives you a 10 character result where the string is padded with leading blanks. You probably would want to use CAST() instead to have more control over your result or specify a length argument for STR().
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply