Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Sean Harvell sean.harvell.ws

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

DBMAIL

// sql server 2005 sample dbmail send

   1  
   2  EXEC msdb.dbo.sp_send_dbmail @profile_name = 'dbmailprofile', @recipients = 'me@co.com,you@cocom', @body = 'the body', @subject = 'the subject'

Simple Raise Error

// simple raise error

   1  
   2  IF UPDATE(lastname)
   3  BEGIN
   4  	RAISERROR ('cannot change lastname (source = instead of)', 16, 1)
   5  	ROLLBACK TRAN
   6  	RETURN
   7  END

SQL Server 2000 RegEx

// SQL 2K RegEx Compat Code

   1  
   2  CREATE FUNCTION dbo.find_regular_expression
   3  	(
   4  		@source varchar(5000),
   5  		@regexp varchar(1000),
   6  		@ignorecase bit = 0
   7  	)
   8  RETURNS bit
   9  AS
  10  	BEGIN
  11  		DECLARE @hr integer
  12  		DECLARE @objRegExp integer
  13  		DECLARE @objMatches integer
  14  		DECLARE @objMatch integer
  15  		DECLARE @count integer
  16  		DECLARE @results bit
  17  		
  18  		EXEC @hr = sp_OACreate 'VBScript.RegExp', @objRegExp OUTPUT
  19  		IF @hr <> 0 BEGIN
  20  			SET @results = 0
  21  			RETURN @results
  22  		END
  23  		EXEC @hr = sp_OASetProperty @objRegExp, 'Pattern', @regexp
  24  		IF @hr <> 0 BEGIN
  25  			SET @results = 0
  26  			RETURN @results
  27  		END
  28  		EXEC @hr = sp_OASetProperty @objRegExp, 'Global', false
  29  		IF @hr <> 0 BEGIN
  30  			SET @results = 0
  31  			RETURN @results
  32  		END
  33  		EXEC @hr = sp_OASetProperty @objRegExp, 'IgnoreCase', @ignorecase
  34  		IF @hr <> 0 BEGIN
  35  			SET @results = 0
  36  			RETURN @results
  37  		END
  38  			
  39  		EXEC @hr = sp_OAMethod @objRegExp, 'Test', @results OUTPUT, @source
  40  		IF @hr <> 0 BEGIN
  41  			SET @results = 0
  42  			RETURN @results
  43  		END
  44  		EXEC @hr = sp_OADestroy @objRegExp
  45  		IF @hr <> 0 BEGIN
  46  			SET @results = 0
  47  			RETURN @results
  48  		END
  49  	RETURN @results
  50  	END
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS