Subquery using Exists 1 or Exists *

No, SQL Server is smart and knows it is being used for an EXISTS, and returns NO DATA to the system. Quoth Microsoft: http://technet.microsoft.com/en-us/library/ms189259.aspx?ppud=4 The select list of a subquery introduced by EXISTS almost always consists of an asterisk (*). There is no reason to list column names because you are just testing whether rows …

Read more

Get the records of last month in SQL server

All the existing (working) answers have one of two problems: They will ignore indices on the column being searched The will (potentially) select data that is not intended, silently corrupting your results. 1. Ignored Indices: For the most part, when a column being searched has a function called on it (including implicitly, like for CAST), …

Read more

Disadvantages of MARS (Multiple Active Result Sets)?

There are apparently at least two known (potential) drawbacks (from this (1) Team blog): Obviously this can cause potential problems for any legacy systems which weren’t designed to run against a MARS enabled design – “existing code optimized to run in the non-MARS world may show a slight performance dip when run un-modified with MARS” …

Read more

What is the difference between Trusted_Connection and Integrated Security in a connection string?

They are synonyms for each other and can be used interchangeably. In .Net, there is a class called SqlConnectionStringBuilder that is very useful for dealing with SQL Server connection strings using type-safe properties to build up parts of the string. This class keeps an internal list of synonyms so it can map from one value …

Read more