Thursday, July 24, 2008

Sample ADO.Net Project

Here is the sample ADO.Net project from class. Download Here I'll post the slides and more examples soon.

Friday, July 18, 2008

SQL Server 2005 - Resetting autoincrementing table id

To reset the auto-incrementing id on a table use the following syntax

declare @newseed int
select @newseed = max(columnName) from tableName
dbcc checkident(tableName, RESEED, @newseed)

Of course substituting your table name for tableName and the id column's name for columnName

Wednesday, July 16, 2008

Changing Case Sensitivity in SQL Server 2005

Here's a great "how-to" on changing your existing db to case insensitive

The bottom line is, create your db's as case insensitive using the default sql server collation settings (for US) of SQL_Latin1_General_CP1_CI_AS.

To find your current case sensitivity using the following

SELECT DATABASEPROPERTYEX(db_name, 'Collation')

For example

SELECT DATABASEPROPERTYEX('AdventureWorks','Collation')

SQL Server 2005 = NULL

I am teaching a SQL Server 2005 class this week and the question of IS NULL vs. = NULL came up. While we know to use IS NULL I couldn't recall when to use = NULL. Here's a great article detailing the use for = NULL.

Understanding the difference between is null and = null