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 2005 Forums
 Transact-SQL (2005)
 Conversion failed when converting the nvarchar

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2012-07-18 : 23:35:21
Hi All,


I got sql statement as below:-

select * from tblEntity where EntityID in (select Replace(SUBSTRING(EntityID, 2, 8000),',',''',''')
from tblUser where UserDomain='aveva\micheale.see')

But when i run, i got error:-
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '2','8','4','11','12','14','15','13','5','6','7','9','16','1','3' to data type int.


Please advise.

Thank you.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-19 : 00:04:46
whats the datatype of EntityID in tblUser?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql-programmers
Posting Yak Master

190 Posts

Posted - 2012-07-19 : 08:01:09
Please check you data in the EntityID column in the tblUsers table. We believe it may alpha numeric values and you are trying to get ID using substring function.

So pls give sample data of the tblUsers and tblEntity table . then only we can give exact solution.

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page
   

- Advertisement -