Never been to CodeSnippets 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

Andrew King

Joining Tables using a Like statement

-- This SQL code allows you to join a table to another table by finding columns that contain another column's information
-- (instead of where the columns are equal)

SELECT *
FROM Table1
INNER JOIN Table2 ON Table1.col LIKE '%' + Table2.col + '%'

Simple Email Address Syntax Validation

// Basic email address syntax validation
// If the address is not formatted properly this will throw an error.

   System.Net.Mail.MailAddress temp = new System.Net.Mail.MailAddress(emailAddress);

Get a date without time in SQL

--Extracts the date from the date time
CAST(FLOOR(CAST(GETDATE() AS float)) AS datetime)

Visual Studio 2003 - "No files were found to look in. Find was stopped in progress."

// If you are trying to do a search and get this error, this should fix this.

- Spin around in your chair 3 times
- Clap your hands
- Hit Control + Scroll Lock and all is fixed

Transfer Type Ahead Information from Outlook

1. Close any running copies of Microsoft Outlook.
2. Open Windows Explorer.
3. Make sure hidden files and folders are visible in Windows Explorer by navigating to Tools -> Folder Options -> Advanced Settings, and select "Show hidden files and folders."
4. Look in the directory %APPDATA%\Microsoft\Outlook for any files with the .NK2 extension. These are the nickname caches. (If they're not visible there, you may need to search the system for any files that match that extension.)
5. Transfer the file to the corresponding directory on another computer with Outlook
6. Restart Microsoft Outlook and all of your type ahead data should be there.

NOTE: This will allow transfers from Office 2003 to Office 2007

Remove Type Ahead Information from Outlook

How to remove type ahead/AutoComplete information from Outlook

Begin typing the address that you want to remove. When the type ahead value that you want to remove is shown, right-click on the type ahead box. You can then use the arrow keys on the keyboard to select the name you want to remove and then press the DELETE key to remove it.

Delete top 1 rows

// Deletes the top 1 row from the table

set rowcount 1
DELETE FROM xxx WHERE xxx
set rowcount 0

Reindex and rebuild statistics for entire database

// Reindex and rebuild statistics for each table in the database

EXEC sp_MSforeachtable "dbcc dbreindex('?')"
EXEC sp_MSforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN'