Tuesday, March 27, 2012

Concat int with string

Hi,

I am trying to concat an int with an nvarchar in my select:

select distinct(id + name)
from load
where name not like '%test%'

but I am getting an error saying:
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the nvarchar value '灪愭楮敭' to a column of data type int.

My question is: how do you concat int and string in MS SQL Server. The equivalent in Oracle would be ||, I think.

Thanks for any help.

Mongodid you try this --

select distinct(cast(id as nvarchar) + name) ...

No comments:

Post a Comment