Call now: (800) 766-1884  



 Home


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA



 Articles
 Services
 SQL Server Scripts
 Scripts Menu



 

 

 

 
 

SQL Server

SQL Server Tips by Gama and Naughter Consulting

 


Testing the Code

As is standard, the XP must be registered before it is used. Please refer to the “test.sql” file included in the XP_REGEXP folder; it handles the standard XP registration code and includes some test cases for each of the three XP’s.

To integrate this XP into a UDF (so that it mirrors the COM implementation provided in Cory Koski’s article), you would use:

CREATE FUNCTION dbo.findRegex
(
@SourceText varchar(8000),
@RegExp varchar(1000),
@CaseSensitive bit
)
RETURNS bit
AS
BEGIN
DECLARE @match bit
EXEC master..XP_REGEXP_ASCII @SourceText, @RegExp, @CaseSensitive, @match OUTPUT
RETURN (@match)
END

An example to check if a time has been entered in h:mm or hh:mm format would be:.

PRINT dbo.findRegex('1:57', '{[0-9]?[0-9]}:{[0-9][0-9]}', 0)
PRINT dbo.findRegex('01/03', '{[0-9]?[0-9]}:{[0-9][0-9]}', 0)

The first example should print “1” while the second should print “0”.

For more examples on using regular expressions as well as detailed information on the syntax for the ATL Server regular expression parser, please refer to the MSDN documentation for the ATL Server classes used.


The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter

 http://www.rampant-books.com/book_2005_2_sql_server_external_procedures.htm

 


 

 

 

Burleson Consulting Remote DB Administration


 

 


 

 

 

 

 
Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.
 


Burleson Consulting
SQL Server database support

 

Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter