SQL LocalDB vs SQL Server CE

See the Introducing SQL Server Express Local DB Runtime presentation – gives a great overview. The huge benefit of LocalDB is that it’s real SQL Server – it’s a special version of SQL Server Express, but it basically supports everything that “real” SQL Server has – spatial data types, stored procedures – you name it. … Read more

What are the main differences between OPTION(OPTIMIZE FOR UNKNOWN) and OPTION(RECOMPILE)?

Will OPTION(OPTIMIZE FOR UNKNOWN) reuse cache instead of recompiling each time? Yes, it will. There are two main differences between OPTION(OPTIMIZE FOR UNKNOWN) and OPTION(RECOMPILE) as can be seen from this quote from MSDN: OPTIMIZE FOR UNKNOWN Instructs the query optimizer to use statistical data instead of the initial values for all local variables when … Read more

Better way for Getting Total Count along with Paging in SQL Server 2012

If we’re allowed to change the contract, you can have: SELECT CSTNO, CSTABBR,COUNT(*) OVER () as TotalCount FROM DBATABC WHERE CSTABBR LIKE ‘A%’ ORDER BY CSTNO OFFSET ( @OffSetRowNo-1 ) * @FetchRowNo ROWS FETCH NEXT @FetchRowNo ROWS ONLY And now the total will be available as a separate column in the result set. Unfortunately, there’s … Read more

Why the SQL Server ignore the empty space at the end automatically?

SQL Server is following the ANSI/ISO standard for string comparison. The article How SQL Server Compares Strings with Trailing Spaces explains this in detail. SQL Server follows the ANSI/ISO SQL-92 specification… on how to compare strings with spaces. The ANSI standard requires padding for the character strings used in comparisons so that their lengths match … Read more

ANSI_NULLS and QUOTED_IDENTIFIER killed things. What are they for?

OK, from an application developer’s point of view, here’s what these settings do: QUOTED_IDENTIFIER This setting controls how quotation marks “..” are interpreted by the SQL compiler. When QUOTED_IDENTIFIER is ON then quotes are treated like brackets ([…]) and can be used to quote SQL object names like table names, column names, etc. When it … Read more