Quantcast
Channel: T-SQL – SQL in the Wild
Browsing all 43 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Functions, IO statistics and the Execution plan

It’s no secret that I’m not overly fond of most user-defined functions. This isn’t just a pet hate, I have some good reasons for disliking them. All too often they’re performance bottlenecks, but that...

View Article



Image may be NSFW.
Clik here to view.

EXISTS vs IN

This one’s come up a few times recently, so I’ll take a look at it. The EXISTS and IN clauses at first glance look fairly similar. They both use a subquery to evaluate rows, but they do it in a...

View Article

Image may be NSFW.
Clik here to view.

IN vs INNER JOIN

Often in forum threads discussing query performance I’ll see people recommending replacing an INNER JOIN with an IN or EXISTS (or recommending replacing an IN or EXISTS with an INNER JOIN) for...

View Article

Image may be NSFW.
Clik here to view.

NOT EXISTS vs NOT IN

Continuing with the mini-series on query operators, I want to have a look at NOT EXISTS and NOT IN. Previous parts of this miniseries are: EXISTS vs IN IN vs INNER JOIN Just one note before diving into...

View Article

Image may be NSFW.
Clik here to view.

Left outer join vs NOT EXISTS

And to wrap up the miniseries on IN, EXISTS and JOIN, a look at NOT EXISTS and LEFT OUTER JOIN for finding non-matching rows. For previous parts, see In vs Exists In vs Inner Join Not in vs Not Exists...

View Article


In, Exists and join – a roundup

Over the last several months I’ve had a look at IN, Exists, Join and their opposites to see how they perform and whether there’s any truth in the advice that is often seen on forums and blogs...

View Article

Image may be NSFW.
Clik here to view.

A Trio of Table Variables

So, it’s the second Tuesday of the month again, and it’s time for T-SQL Tuesday again. This month it’s hosted by Sankar Reddy and the topic is “Misconceptions in SQL Server” I thought I’d tackle a trio...

View Article

On Transactions, errors and rollbacks

Do errors encountered within a transaction result in a rollback? It seems, at first, to be a simple question with an obvious answer. Transactions are supposed to be atomic, either the entire...

View Article


Image may be NSFW.
Clik here to view.

Converting OR to Union

When I looked at indexing for queries containing predicates combined with OR, it became clear that the are some restrictive requirements for indexes for the optimiser to consider using the indexes for...

View Article


Image may be NSFW.
Clik here to view.

Goodbye IsNumeric hell

A well overdue feature introduced in Denali CTP 3 is that of the Try_Parse and Try_Convert functions. These are great for dealing with the something that’s frustrated SQL developers for years – data...

View Article

Image may be NSFW.
Clik here to view.

A Mess of Nested Transactions

Transactions are an area that I often find are used badly, or not used at all. Transactions without any error handling, nested transactions, named transactions named for no good reason or just plain...

View Article

Image may be NSFW.
Clik here to view.

Savepoints and conditional transactions

This is the second in a short series on transactions. In the previous part I discussed nested transactions and showed that they actually don’t exist. SQL has syntax which may suggest that nested...

View Article

Image may be NSFW.
Clik here to view.

Why would you want to name a transaction?

Something that i keep seeing in documentation, in forum code and in real systems is transactions that have names BEGIN TRANSACTION VeryImportantProcess <do stuff> COMMIT VeryImportantProcess Now...

View Article


Image may be NSFW.
Clik here to view.

When naming transactions causes an error

For the last part of the series on transactions, I’m going to look at a problem that I ran across entirely by chance while doing some performance tuning. A procedure had a transaction in it, and it was...

View Article

Image may be NSFW.
Clik here to view.

Does an index scan always read the entire index?

No. That’s a bit short for a blog post, so let me explain. First, the difference between a seek and a scan. A seek is an operation which navigates down the index’s b-tree looking for a row or for the...

View Article


Image may be NSFW.
Clik here to view.

On the addition of useless where clauses

I remember a forum thread from a while back. The question was on how to get rid of the index scan that was in the query plan. Now that’s a poor question in the first place, as the scan might not be a...

View Article

Image may be NSFW.
Clik here to view.

and other pointless query rewrites

In a similar vein to last week’s blog post… I heard an interesting comment recently. “Change that Column != 2 to a Column > 2 or Column < 2 combination, it can use indexes better.” Sounds like...

View Article


Image may be NSFW.
Clik here to view.

SQL Server 2016 features: Temporal Tables

Another new feature in SQL 2016 is the Temporal Table (or System Versioning, as its referred to in the documentation). It allows a table to be versioned, in terms of data, and for queries to access...

View Article

Image may be NSFW.
Clik here to view.

What is a SARGable predicate?

‘SARGable’ is a weird term. It gets bandied around a lot when talking about indexes and whether queries can seek on indexes. The term’s an abbreviation, ‘SARG’ stands for Search ARGument, and it means...

View Article

Image may be NSFW.
Clik here to view.

Goodbye IsNumeric hell

A well overdue feature introduced in Denali CTP 3 is that of the Try_Parse and Try_Convert functions. These are great for dealing with the something that’s frustrated SQL developers for years – data...

View Article
Browsing all 43 articles
Browse latest View live




Latest Images