Reset an identity column's seed to 1

Cant truncate table because of FK:s? Delete all rows. Then use this script to reset identity seed to 1.

SSMS refresh auto-complete cache

Did you ever change the schema in SSMS and the queries gets red-underlined as the syntax is errorous cause the "spell checker" does not have the altered schema information?

Re-map an existing database user to an existing SQL Server login

After a database restore the database will have its user but the SQL Server login havent't been created. Fix the mapping by adding the SQL Server login and then map them together using sp_change_users_login sproc.

Use the smallest SQL Server datatypes for great performance

A lookup table with 10 records can have a PK of int or tinyint. Thats 3 bytes in difference. A 1 million record table referencing that table will then use either 4,000,000 or 1,000,000 bytes. That column will probable be part in an index. That index tree will be bigger and take more time to process, and using more RAM and CPU. Query will take longer and tables are locked a longer time. It is easy to choose a smaller datatype and you will gain much performance from doing so.

Keep SQL DML simple and free from any kind of logic

Let SQL Server be able to process data as effective as possible and do not confuse the optimizer and query plan caching mechanisms with logic in your SQL code.

ISO Week in SQL Server 2008 DATEPART fx

Finally we got it... This will make working with weeks in Europe a lot more easy.

Transfer SQL Server Database

Transfer both schema and data using the database publishing wizard and sqlcmd. But where is the Database Publishing Wizard for SQL Server 2008. And what to do when the generated script is huge?

Remove the time portion from a datetime

Instead of converting datatypes (to varchar) back and forth, this is much faster.

Sleep in T-SQL

Make the execution of an SQL script sleep for a certain amount of time.

Comma delimited string from row values using COALESCE or FOR_XML

This is how to get a comma delimited string from row values using COALESCE or FOR_XML

Execution time and IO for SQL Statements

Display stats for individual SQL execute statements.

Orchard database lacks referential integrity

I took a quick look at the schema of the Orchard database. There's some tables there but it seemed to lack any FK constraints.