Remove sql-isnull-function-2
article thumbnail

Additional T-SQL Improvements in SQL Server 2022

SQL Performance

Recently I covered some of the T-SQL improvements in SQL Server 2022 here , and Aaron Bertrand covered additional improvements here. Microsoft just announced the release of SQL Server 2022 CTP 2.1. This release includes a number of additional interesting T-SQL improvements, which include: The distinct predicate.

Servers 142
article thumbnail

Matching Supply With Demand — Solutions, Part 1

SQL Performance

Following is the desired result for the small set of sample data: DemandID SupplyID TradeQuantity -- -- -- 1 1000 5.000000 2 1000 3.000000 3 2000 6.000000 3 3000 2.000000 5 4000 2.000000 6 5000 4.000000 6 6000 3.000000 6 7000 1.000000 7 7000 1.000000. and the second (ID 2) is for a quantity of 3.0. Auctions ; SET IDENTITY_INSERT dbo.

Code 116
Insiders

Sign Up for our Newsletter

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Trending Sources

article thumbnail

NULL complexities – Part 1

SQL Performance

NULL handling is one of the trickier aspects of data modeling and data manipulation with SQL. Even among people who do have a good grasp of relational theory and SQL, you will hear very strong opinions both in favor and against using NULLs in your database. In SQL, a NULL is a marker, or a placeholder, for a missing value.

article thumbnail

T-SQL bugs, pitfalls, and best practices – pivoting and unpivoting

SQL Performance

This article is the fifth part in a series about T-SQL bugs, pitfalls and best practices. When people want to pivot data using T-SQL, they either use a standard solution with a grouped query and CASE expressions, or the proprietary PIVOT table operator. 3 0 0 1 1 0 0 1 2 0 0 1 1 0 0 1 2 0 0 1 1 0 0 1 3 0 0 1 3 0 0 1 2 0 1 0.

article thumbnail

Overlooked T-SQL Gems

SQL Performance

The relevance to T-SQL is that sometimes we assume that we know everything there is to know about certain T-SQL features, and don't always bother checking the documentation to see if there's more to them. The EOMONTH function was introduced in SQL Server 2012. In my examples I'll use a sample database called TSQLV5.

C++ 111
article thumbnail

NULL Complexities – Part 2

SQL Performance

Last month I introduced the NULL as SQL's marker for any kind of missing value. I explained that SQL doesn't provide you with the ability to distinguish between missing and applicable (A-values) and missing and inapplicable (I-values) markers. This article is the second in a series on NULL complexities.

Design 65
article thumbnail

Number series generator challenge solutions – Part 5

SQL Performance

In Part 1 , Part 2 , Part 3 and Part 4 I covered pure T-SQL solutions. Many thanks to Alan Burstein, Joe Obbish, Adam Machanic, Christopher Ford, Jeff Moden, Charlie, NoamGr, Kamil Kosno, Dave Mason, John Nelson #2, Ed Wagner, Michael Burbea, and Paul White for sharing your ideas and comments. I covered this solution in Part 1.

C++ 111