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 2000 Forums
 SQL Server Development (2000)
 Delimited Search

Author  Topic 

mash
Starting Member

1 Post

Posted - 2000-11-20 : 20:49:36
Here's a bit of ASP to delimit a string for search and use the space as a a delimiter. However this filters out the spaces in the event of 3 of them at once as this would find a space and send the server into Bannana land !

Is there a way of doing this in SQL as maybe a funtion of sorts ....

Bit of an advanced newbie ;-)

Function SQLSearch(Fld , Datai )
Dim T , arr, lwp, frsT
frsT = True
arr = Split(Datai, " ")
For lwp = LBound(arr) To UBound(arr)
If arr(lwp) <> "" Then
If Not frsT Then
T = T & " and " & Fld & " like '%" & Replace(arr(lwp), "'","''") & "%' "
Else
T = T & Fld & " like '%" & Replace(arr(lwp), "'", "''") & "%' "
frsT = False
End If
End If
Next
SQLSearch = T
End Function



TIA
Mash

nb nice site and fast too ... Keep it up

   

- Advertisement -