I'm looking to convert a SQL like statement on the fly to the equivalent regex i.e.
LIKE '%this%'
LIKE 'Sm_th'
LIKE '[C-P]arsen'
What's the best approach to doing this?
P.S. I'm looking to do this on the .Net Framework (C#).
...
Hi to all, I'm trying to get a query working that takes the values (sometimes just the first part of a string) from a form control. The problem I have is that it only returns records when the full string is typed in.
i.e. in the surname box, I should be able to type gr, and it brings up
green
grey
graham
but at present it's not bring...
I just read a post mentioning "full text search" in SQL.
I was just wondering what the difference between FTS and LIKE are. I did read a couple of articles but couldn't find anything that explained it well.
Thanks.
...
Taking over some code from my predecessor and I found a query that uses the Like operator:
SELECT * FROM suppliers
WHERE supplier_name like '%'+name+%';
Trying to avoid SQL Injection problem and parameterize this but I am not quite sure how this would be accomplished. Any suggestions ?
note, I need a solution for classic ADO.NET - I d...
How do I escape a string in SQL Server's stored procedure so that it is safe to use in LIKE expression.
Suppose I have an NVARCHAR variable like so:
declare @myString NVARCHAR(100);
And I want to use it in a LIKE expression:
... WHERE ... LIKE '%' + @myString + '%';
How do I escape the string (more specifically, characters that ar...
The following doesn't work, but something like this is what I'm looking for.
select *
from Products
where Description like (@SearchedDescription + %)
SSRS uses the @ operator in-front of a parameter to simulate an 'in', and I'm not finding a way to match up a string to a list of strings.
Help!
...
I know this is a pretty basic question, and I think I know the answer...but I'd like to confirm.
Are these queries truly equivalent?
SELECT * FROM FOO WHERE BAR LIKE 'X'
SELECT * FROM FOO WHERE BAR ='X'
Perhaps there is a performance overhead in using like with no wild cards?
I have an app that optionally uses LIKE & wild cards. T...
So, I have a method that performs a parametrised LIKE query. The method takes in the search parameter/value in and then it is added to the command ready for the query.
It is not working. It should work, and when I code the value to search for directly into the SQL string, sans parametrisation, it does work! When I have it as a paramete...
I have a search query that I'm inheriting and attempting to optimize. I am curious to hear if anyone has any best practices and recommendations for such. The production server is still SQL Server 2000 also.
The query is an advanced customer search stored procedure that accepts 5 different search criteria parameters (i.e. first name, la...
I have a List<string> of variable count, and I want to query (via LINQ) a table to find any items that contain any of those strings in the Text column.
Tried this (doesn't work):
items = from dbt in database.Items
where (stringList.FindAll(s => dbt.Text.Contains(s)).Count > 0)
select dbt;
Query would be something li...
Hi All,
I've inherited the code below but I'm puzzled as the code works just fine but I'm not convinced it's correct. I've not used LIKE before so I can't decide if I should bother changing this. How does this look to you?
The code is for a filter in a db it checks if X value contains Y value, find X* in X (e.g. Match would be F* in Fu...
I am trying to find a way to query rows of data by using a "multivalue" pipe delimited column in another table as a WHERE clause. SQL SERVER 2005
This is my best description of the problem:
Imagine a pipe delimited column set to a variable like @LIST = 'Bob|Mary|Joe'
then I am trying to find a match like this
Select * from Users...
I want to match an input string to my PHP page the same way a match done by the LIKE command in SQL (MySQL) for consistency of other searches. Since (I have seen but don't comprehend) some of the PHP syntax includes SQL commands I am wondering if this is possible?
The reason for this is I am now implementing a search of a keyword versu...
I am having some problems with linq to entities in the ado.net entity framework. Basically what I'm doing is this:
var results = (from c in companies
where c.Name.StartsWith(letter)
select c);
and this gets translated to SQL as something like:
WHERE (CAST(CHARINDEX(@p, [Extent1].[Name]) AS int)) = 1
which is fine but my table has...
I want to search for a number embedded in a string in a field in our log table using a parameter.
select * from vwLogs
where log_time >'02/24/2009' and
message like ('%2009022508241446%')
I know how to use parameters when the where clause is an equals sign but not sure how to do it with 'Like'
this doesn't seem right
WHERE message l...
Using these tables, as a sample:
Table CodeVariations
CODE
-----------
ABC_012
DEF_024
JKLX048
And table RegisteredCodes
CODE AMOUNT
-------- ------
ABCM012 5
ABCK012 25
JKLM048 16
Is it possible to write a query to retrieve all rows in RegisteredCodes when CODE matches a pattern in any row of the Cod...
I'm doing a large import from a comma delimited file and want to lookup an employer id during the sproc that is executed at the end of the import process. The issue I'm having is that my LIKE doesn't seem to work ... so I wanted to see if the syntax is correct.
Note - This will update all the records = the employer name but anything LI...
Hello,
I know this may be something stupid but I decided to ask any way.
I've been trying to query something like:
cursor.execute("select col1, col2 \
from my_tablem \
where afield like '%%s%'
and secondfield = %s
order by 1 desc " % (var1, var2) )
Bu...
Anyone know how to combine PHP prepared statements with LIKE? i.e.
"SELECT * FROM table WHERE name LIKE %?%";
...
Hi!
I am trying to match column values returned, but values are returned as a result of pattern matching:
select app.employees.id, app.employees.name, app.employees.current_bp,
app.designation.designation from app.employees, app.designation
where app.employees.id like 'khsn?' = app.designation.desig_id like 'khsn?';
As you can see,...