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)
 Syntax error converting varchar to int.

Author  Topic 

zubamark
Starting Member

23 Posts

Posted - 2008-06-13 : 12:59:46
Hello,

I have table1
ID PATH
1 .166.184.185.186.

Need get data from table2 using PATH data from table1
select * from table2 where id in (
select Substring(replace(path,'.',','),2,Len(path)-2) from table1)
ERROR:
Syntax error converting the varchar value '166,184,185,186' to a column of data type int.

Any solution please.

Regard,
M.Z.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-13 : 13:03:07
May be this:-
SELECT *
FROM table2 t2
INNER JOIN table1 t1
ON t1.PATH LIKE '%.'+ CAST(t2.id as varchar(5)) + '.%'
Go to Top of Page

zubamark
Starting Member

23 Posts

Posted - 2008-06-13 : 13:26:48
It works. Thanks
Go to Top of Page
   

- Advertisement -