how to concate two integers in select statement

  • Thread starter Thread starter haiwen
  • Start date Start date
H

haiwen

hello, everyone:

we can concate two strings when changing column name, such
as: select firstname +' ' + lastname as name from user;

but how can I concate two intergers(treat them as strings)?
when I use +, I alway get the result of addition.

Thanks

haiwen
 
try convert.ToString(number1) + convert.ToString(number2).

if you want to convert the result to a number then wrap the above command
around a

convert.ToInt64 command.

hope this helps, let me know!

:)
 
You need to CONVERT/CAST the columns into string (VARCHAR)
first then add them.

Tu-Thach
 
hi, thank you for your help.

I try it, but I get the exception:

Exception Details: System.Data.SqlClient.SqlException:
Line 1: Incorrect syntax near '.'.

it seems it doesn't reconize the convert.ToString(number1)
I use C#.

Is there other way to do it,

thanks again.

haiwen
 
that goes in the SQL statement. It is processed by SQL, not .net

--
==========================================
= Tom Vande Stouwe MCSD.net, MCAD.net, MCP
= 45Wallstreet.com (www.45wallstreet.com)
= (803)-345-5001
==========================================
= If you are not making any mistakes
..= ..you are not trying hard enough.
==========================================
 
Back
Top