Never been to TextSnippets 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 (or not, you can keep them private!)

About this user

Sean Harvell sean.harvell.ws

« Newer Snippets
Older Snippets »
5 total  XML / RSS feed 

Replace text in a TEXT type data column

// Replace text in a TEXT type data column

SELECT     REPLACE(SUBSTRING(Note, 1, DATALENGTH(Note)), CHAR(13), '
') AS Expr1 FROM OLD_NOTES

Simple COALESCE example

// Simple COALESCE example

--If all arguments are NULL, COALESCE returns NULL.
COALESCE(expression1,...n) 
--is equivalent to this CASE function:
CASE
WHEN (expression1 IS NOT NULL) THEN expression1
--...
WHEN (expressionN IS NOT NULL) THEN expressionN
ELSE NULL

csharp app.path

// csharp app.path

public static string AppPath()
{return AppDomain.CurrentDomain.BaseDirectory;}

Simple TSQL cursor

// Simple TSQL cursor

        declare @email nvarchar(255)
        declare CustList cursor for
                SELECT email from STE_EMAILS
        OPEN CustList
        FETCH NEXT FROM CustList 
        INTO @email
        WHILE @@FETCH_STATUS = 0
        BEGIN
          if (SELECT count(custid) from leads where (current_customer=1) and (notes1 is not null) and (notes1 like '%' + @email + '%')) > 0
                SELECT custid from leads where (current_customer=1) and (notes1 is not null) and (notes1 like '%' + @email + '%')
                print '%' + @email + '%'
          FETCH NEXT FROM CustList INTO @email
        END
        CLOSE CustList
        DEALLOCATE CustList

Quick Mail class

// Quick Mail class

    static class QuickMail
    {
        public static void SendMail(string from, string to, string subject, string messageText, bool isHtml)
        {
                        SmtpClient mymail = new SmtpClient(ConfigurationManager.AppSettings["localsmtp"]);
                        MailMessage message = new MailMessage(from, to, subject, messageText);
                        message.IsBodyHtml = isHtml;
                        mymail.Send(message);
        }
    }
« Newer Snippets
Older Snippets »
5 total  XML / RSS feed