Monday, September 19, 2011

Database mail log using TSQL (Just Learned)

SYSMAIL_ALLITEMS is a view in MSDB database is used to check database mail log .
Contains one row for each message processed by Database Mail. This is really helpfull view to troubleshoot notifications .


Monday, September 5, 2011

Count String Occurrence SQL Server

Sometime we have to count the occurrence of any specific string like :

Declare @Input NVarchar(Max)
Set @Input = 'A92GPGCatherineGeorgeB2VZ9VCARMENNAVARROARAUZ'

Here we have to count the occurrence.
so we can get this by using simple script :

Select (LEN(@Input) - LEN(REPLACE(@Input, '', ''))) / LEN('')

Thanks...