This is a discussion on Sql query with a stringfunction within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi... I have a problem. I need a query that can handle to search throu a string, here called ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi... I have a problem. I need a query that can handle to search throu a string, here called mylist. if lF08.postNr is in mylist all is ok. mylist="115, 116, 117, 118, 119, 120" Something like this strSQ = "SELECT DISTINCT * from lF08, m08 where instr(lF08.postNr,mylist) AND lF08.memberNr=m08.memberNr order by ort DESC" I know i can't use the function instr, but how can i solve this. Is there a function for this? I use sql-server 2000 Regards mikael |
| |||
| "majsen" <mikael@home.staertesjoen.se> wrote in message news:58316675.0409130359.31a71d13@posting.google.c om... > Hi... > > I have a problem. I need a query that can handle to search throu a string, > here > called mylist. if lF08.postNr is in mylist all is ok. > > mylist="115, 116, 117, 118, 119, 120" > > Something like this > > strSQ = "SELECT DISTINCT * from lF08, m08 where > instr(lF08.postNr,mylist) AND lF08.memberNr=m08.memberNr order by ort > DESC" > > I know i can't use the function instr, but how can i solve this. Is there > a function for this? I use sql-server 2000 > > Regards mikael Assuming myList is a string, then one way is to build the query string on the front end: strSQ = " SELECT DISTINCT * from lF08 join m08 onlF08.memberNr=m08.memberNr where lF08.postNr in (" + myList + ") order by ort DESC" This article explains how to use a server-side approach: http://www.sommarskog.se/arrays-in-sql.html Simon |
| ||||
| Thanks! Nice pice of code... Regards mikael *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
| Thread Tools | |
| Display Modes | |
|
|