Tag: INT

DBCC ShrinkDatabase

Being day 24 of the DBCC Command month at SteveStedman.com, today’s featured DBCC Command is DBCC SHRINKDATABASE. When I first heard about DBCC Shrink Database (many years ago), I immediately thought “what a great feature, run this every night when

Posted in DBCC Commands Tagged with: , , , , , , , , , , , , ,


Here is a quick rundown on the T-SQL DATEPART function for SQL Server. DATEPART is used to pull a single part of a date/time element out as shown below. The following query uses DATEPART to extract the year from the

Posted in TSQL Tagged with: , , , , ,

Are you wasting half the capacity of IDENTITY?

When creating a table you can specify IDENTITY with the following syntax: For example The IDENTITY property is valid for data types of the integer data type category, except for the bit data type, or decimal data type.  So how

Posted in Database Health Tagged with: , , , , , , , ,

CTE – With An Insert Statement

Queries with Common table expressions (CTE) are made up of two parts, the CTE part, and the SQL that references the CTE.  In preparation for SQL Saturday, the question came up of can you use an INSERT or UPDATE statement

Posted in CTE, SQL Saturday Tagged with: , , , , ,

Free – Duplicate Indexes Report – Updated

After creating and deploying the duplicate indexes report earlier today I discovered that although the report did exactly what it says, it didn’t do what I needed. The earlier  duplicate indexes report only found indexes that were an exact match on the

Posted in Server Health, SQL Saturday Tagged with: , ,

Index Fragmentation and SHRINKDATABASE

Is it a good idea to run DBCC SHRINKDATABASE regularly? Download the sample file ShrinkSample. This article and samples apply to SQL Server 2005, 2008, and 2008R2. This really depends on a number of factors, but generally the answer is

Posted in Performance Tagged with: , , , , , , ,

MSG 128, Level 15, State 1 – not permitted in this context

Default Values and Computed Columns In SQL Server 2008, I was presented with the following error when attempting to create a table that has a default value that references other columns in the same table. Msg 128, Level 15, State

Posted in DBA, TSQL Tagged with: , , , , , , ,

Query SQL Server 2008 Total Memory Usage

The quick and easy way to determine how much memory your SQL Server is using is to look at the Task Manager on the server and find “sqlservr.exe” in the process list, and look at the “Mem Usage” column. But

Posted in DBA Tagged with: , , , , , ,