kapricanon
kapricanon

Reputation: 179

Why can't I use regex in Sybase SQL

I am using this version of Sybase -

Adaptive Server Enterprise/15.5/EBF 18164 SMP ESD#2/P/x86_64/Enterprise Linux.

When I try to run the below query I get an error saying Incorrect syntax near 'regexp'.

SELECT * FROM T1 WHERE C1 regexp '.*'

Can someone suggest an alternative if this is not supported in this version of ASE.

Upvotes: 1

Views: 13720

Answers (2)

Luke Guyton
Luke Guyton

Reputation: 1

Naively, you could either construct a varchar(nn) of characters that you want to find, or conversely, know the set of valid characters and search for any NOT in that set.

declare @mySet varchar(255)
select @mySet = '%[' + char(128) + char(129) + ... + ']%'
-- OR 
select @mySet = '%[^A-Z0-9_-@.]%' -- for example, case insensitive
-- then
select * from T where C like @mySet

Upvotes: 0

Robert
Robert

Reputation: 25753

Try this way:

SELECT * FROM T1 WHERE C1 like '%.%'

or

SELECT * FROM T1 WHERE C1 like '%[.]%'

Upvotes: 1

Related Questions