devxlogo

SQL

Import Excel Data into SQL

In order to read from an Excel Spreadsheet through SQL you need to install the Office 2010 Database Engine. Afterwards, run statements similar to the following: EXEC sp_configure ‘Show Advanced

Finding Collations

To?find?Collations?in?your?table,?you?can?use?the?following: SELECT ????SysCol.Name,?SysCol.Collation_Name FROM? ????sys.Columns?SysCol WHERE ????Object_ID?=?OBJECT_ID(‘YOUR_TABLE_NAME’)

Display the Contents of a Stored Procedure

A trigger is a stored procedure that runs automatically when various events happen (update, insert, delete, etc.) To display the contents of a Trigger, use a query similar to the

Handy Function to Test for Email Validity

Use this nifty function to check the validity of an email address. CREATE FUNCTION [dbo].[fnCheckEmail](@Email VARCHAR(255)) RETURNS BIT AS BEGIN DECLARE @ValidEMail BIT IF @Email IS NOT NULL SET @Email

How to Include All Values in a Date Range

Sometimes when doing a search for data between date ranges, some of the data is omitted because the search doesn’t include the whole last day’s values. Here is a small