Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 84
  • Last Modified:

regular expression in sql server

Ok, how can I write a regular expression which can tell me a particular row data is not correct date, out of a column , in a table with millions of records

column 1
01-Jan-15
01-Jan-15
01-Jan-15
01-Jan-15
01/Jan/15

what regular expression will return me row no. 5 from above table.
0
BeyondBGCM
Asked:
BeyondBGCM
  • 2
  • 2
1 Solution
 
PaulCommented:
what version of SQL Server is it?

At SQL 2012 TRY_CAST() is available.

select
*
from table1
where try_cast(column1 as date) IS NULL

but the problem with this is performance my be poor on a large table (but the same is likely to be true with alternatives).
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I confirm that sql server as such does not have have regular expressions.
eventually you don't need such thing, maybe this would be enough already:

where not like '[0-9][0-9]-[JFMASOND][AEPUCO][NBRYLGPVTC]-[0-9][0-9]'
0
 
BeyondBGCMAuthor Commented:
but, we can use regular expressions in .net since 1.1 release
0
 
BeyondBGCMAuthor Commented:
ie from 2003
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, in .Net, but not in sql server directly
using .net means you would have to bring all the relevant table data from the server to the .net app
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now