Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Conversion failed when converting the nvarchar val

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2014-11-03 : 06:23:12
Hi

I have a stored procedure that take a nvarchar value as in parameter (@AvdId nVarChar(500))

And then I have that as a criteria in the sp like this ..

AND (';'+@AvdId+';' LIKE '%;'+CAST(dbo.SurveyAnswerInfo.AvdId AS VARCHAR(32))+';%' OR @AvdId = 0)

This works if I have pass in this value '@AvdID = N'45'

but this does not work...

@AvdID = N'45;48;49;50;51;1'


I then get this error..

Conversion failed when converting the nvarchar value '45;48;49;50;51;1' to data type int.

What am I missing here?

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-11-03 : 07:15:51
[code]
OR @AvdId = '0')
[/code]


sabinWeb MCP
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2014-11-04 : 08:08:04
Great, thanks a lot!
Go to Top of Page
   

- Advertisement -