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
 General SQL Server Forums
 New to SQL Server Programming
 about "like" and patterns

Author  Topic 

smile
Starting Member

22 Posts

Posted - 2009-04-10 : 14:52:11
Hello!

How can I mark that for example - the companyname contains the name of the suppliername? I mean that in this case the pattern contains some already known string like 'abc'. Here the contained string is not known but it's something like parameter...?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-10 : 15:18:28
Could you show us a few data examples of what you mean?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

smile
Starting Member

22 Posts

Posted - 2009-04-10 : 15:38:19
Ok...here's an example query: retrieve all the names of companies from the table Suppliers(Companyname,Suppliername), that contain in their names a name of a supplier.

e.g. The company "Tomaty" contains the name of the supplier "Tom"
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-10 : 15:56:21
SELECT CompanyName
FROM Suppliers
WHERE CompanyName LIKE '%' + SupplierName + '%'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

smile
Starting Member

22 Posts

Posted - 2009-04-10 : 16:37:39
Ah...yeah...I should have guessed it :) Thanks a lot!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-11 : 05:36:46
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -