Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Full-Text Search / July 2004

Tip: Looking for answers? Try searching our database.

REGEXP in sql

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PuOn - 02 Jul 2004 10:33 GMT
i'm trying do this in sql:
the mysql query:
"SELECT id FROM browser WHERE '$http_user_agent' REGEXP browser_regexp"

where $http_user_agent is a string i.e."mozilla/4.0 (compatible; msie 6.0; windows nt 5.0; .net clr 1.1.4322" and the browser_regexp is column in table "browser" with values "msie.6","opera.6",..etc.

the result should be an id where $http_user_agent contains any value from browser_regexp

in mysql worked prefectly, now i'm trying to convert it to sql.
LIKE don't work for me, but maybe i'm not using it correctly...
please  help, thanks
John Kane - 02 Jul 2004 15:33 GMT
PuOn,
In T-SQL for SQL Server 2000, you need to reference the column name
(Column_name) of the table (browser) in the WHERE clause where you have the
string "$http_user_agent", for example:

SELECT id FROM browser WHERE Column_name

as there is no direct equalivant T-SQL syntax fro "REGEXP", except for LIKE
and PATINDEX that used together or separtly should suit your needs.

Review SQL Server 2000 Books Online (BOL) titles "Pattern Matching in Search
Conditions" and "PATINDEX" as well as "Comparing CHARINDEX and PATINDEX"

--Patindex T-SQL example:
use Northwind
select Description from Northwind.dbo.Categories
  where patindex('%[b,B]read%',description) > 0
    and patindex('_[^e]%',description) = 1
/* -- returns:
Description
---------------------------------------
Breads, crackers, pasta, and cereal

(1 row(s) affected)
*/

Hope this helps,
Regards,
John

> i'm trying do this in sql:
> the mysql query:
> "SELECT id FROM browser WHERE '$http_user_agent' REGEXP browser_regexp"
>
> where $http_user_agent is a string i.e."mozilla/4.0 (compatible; msie 6.0; windows nt 5.0; .net clr 1.1.4322" and the browser_regexp is column in table
"browser" with values "msie.6","opera.6",..etc.

> the result should be an id where $http_user_agent contains any value from browser_regexp
>
> in mysql worked prefectly, now i'm trying to convert it to sql.
> LIKE don't work for me, but maybe i'm not using it correctly...
> please  help, thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.