Quantcast
Channel: SQL Server Expert – SQL Steve
Browsing latest articles
Browse All 9 View Live

Image may be NSFW.
Clik here to view.

Execute T-SQL Batches in a Loop

In T-SQL, the keyword “GO” is the default batch separator. For example: DELETE FROM     ErrorLog WHERE     ErrorTime < ’2008-01-01′ GO   But what if you have billions of rows in the “ErrorLog” table...

View Article


Image may be NSFW.
Clik here to view.

EXISTS vs. COUNT(*)

Often times I see the following query used to determine if records exist: IF ((SELECT COUNT(*) FROM Business) > 0) BEGIN –Do some stuff END My first guess would be that SQL Server would actually...

View Article


Image may be NSFW.
Clik here to view.

SQL Server 2008 Infrastructure Planning and Design Guide

The new IPD (Infrastructure Planning and Design) Guide for SQL Server 2008 was released late last month.  This guide serves as a high level review of many of the key considerations when implementing a...

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.

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.

Type Conversion Precedence

Here’s an interesting question: What is the resulting data type of the following query? SELECT’38’ UNION SELECT 94 The answer is an “int”.  The reason for this is SQL Server’s precedence order.  It...

View Article

Browsing latest articles
Browse All 9 View Live