Quantcast
Browsing all 20 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

How to use CASE in a CHECK Constraint

If you need to use a CASE statement in a check constraint, you may be inclined to use something like this: use AdventureWorks2008 GO ALTER TABLE Person.EmailAddress ADD CONSTRAINT...

View Article


Image may be NSFW.
Clik here to view.

SQL Server DateTime Format Function

Creating a DateTime Format Function While it is possible to format dates using T-SQL, it is not always efficient.  Sure there are a million custom format functions available and you can even use the...

View Article


Image may be NSFW.
Clik here to view.

Finding Object References in SQL Server 2005 & 2008

You can use the following query to search through all of the code in a SQL Server database for a given string.  This is often useful when identifying dependencies in code.   –Make sure to set the...

View Article

Image may be NSFW.
Clik here to view.

Pad a Number with Zeros – SQL Server 2005 and SQL Server 2008

If you need to pad a number with zeros do the following: Convert the number to a string padded with spaces by using the STR function. Replace the spaces with 0’s.   DECLARE @NumberToPad INT;    SET...

View Article

Image may be NSFW.
Clik here to view.

Building Indexes Online Creates Larger Indexes

When I create an index on a table, I usually run a script of mine that among other things gives me the size of the created index.  This allows me to see for example if the overhead of compressing the...

View Article


Image may be NSFW.
Clik here to view.

Parameters in SQL Server XPath Queries

If you have forgotten the syntax for using parameters in XPath queries within SQL Server 2005 and SQL Server 2008 the following should refresh your memory. Hard coded example: SELECT        * FROM...

View Article

Image may be NSFW.
Clik here to view.

How to: list all primary keys in a database

I recently had the following question posted to this site: Hello, I’d think this is a simple question/problem.  I want to get the primary key name for each table in my schema.  By doing so, it will...

View Article

Image may be NSFW.
Clik here to view.

Long Running Task Progress Report

There are many operations that take a long time to execute in SQL Server including the following:   ALTER INDEX REORGANIZE AUTO_SHRINK option with ALTER DATABASE BACKUP DATABASE DBCC CHECKDB DBCC...

View Article


Image may be NSFW.
Clik here to view.

Index Statistics and AUTO_UPDATE_STATISTICS

I recently worked with a client that uses a SQL Server 2008 data warehouse and was having performance issues while loading data.  There were a number of issues to address, but one of the issues...

View Article


Image may be NSFW.
Clik here to view.

SQL Server 2008 Data File Size

Sql Server Consultant – Steve Abraham SQL Server Consultant ~ Steve Abraham provides tips for capturing size and state of data files for SQL Server databases. If you are looking to capture the size and...

View Article

Image may be NSFW.
Clik here to view.

How to: list all primary keys in a SQL Server database

I recently had the following question posted to this site: Hello, I’d think this is a simple question/problem.  I want to get the primary key name for each table in my schema.  By doing so, it will...

View Article

Image may be NSFW.
Clik here to view.

How to: Determine SQL Server Transaction Log Space Usage

I have a client that recently asked me if the transaction log of one of his databases was being truncated on a regular basis.  The database was using the “simple” recovery model and as such is...

View Article

Image may be NSFW.
Clik here to view.

How to: Rebuild or Reorganize All Indexes in a SQL Server database

Sometimes, you just need a quick and to the point script to rebuild or reorganize (defragment) all of the indexes in all of the tables of your SQL Server database.  Well, here it is: –Disable row...

View Article


Image may be NSFW.
Clik here to view.

How to: Enable CLR (Common Language Runtime) in SQL Server

With the release of SQL Server 2005 it became possible for developers to write C# or VB.NET code that can execute within SQL Server.  One thing that is often times overlooked when installing a .NET...

View Article

Image may be NSFW.
Clik here to view.

How to: Check the time of the last clean DBCC CHECKDB in SQL Server

DBCC CHECKDB is a common maintenance task executed to verify that the data stored in a SQL Server database is clean (i.e. not corrupt).  Generally speaking, it is good practice to run DBCC CHECKDB...

View Article


Image may be NSFW.
Clik here to view.

How to: Understanding the SQL Server FILLFACTOR setting

What is Fill Factor? When dealing with index design in SQL Server one of the single most important things to configure is the fill factor.  The fill factor is a number between 0-100 which indicates how...

View Article

Image may be NSFW.
Clik here to view.

How to: Identify the object stored at a given page location–SQL Server

Often times when troubleshooting performance issues with SQL Server, you will identify a file id and a page id that is the source of your troubles.  The question is: How do I translate this File Id /...

View Article


Image may be NSFW.
Clik here to view.

How to: Identify SQL Server Transaction Log Usage by Table

The transaction log of a SQL Server database is often misunderstood.  In short, the transaction log records every change made to the database.  Yes, that’s right – every change.  As such, depending on...

View Article

Image may be NSFW.
Clik here to view.

SQL Server–List data file sizes

Here is a quick script to identify just the size of the data files for all of the databases on a given instance of SQL Server. use master GO   SELECT     sys.databases.name AS DatabaseName,...

View Article

Image may be NSFW.
Clik here to view.

SQL Server–Database Configuration Report

When coming in to a new environment, it’s a good idea to get a baseline of all of the databases on each of the systems in the environment.  The script below will generate a report of all of the...

View Article
Browsing all 20 articles
Browse latest View live