There are a few subtleties when using SELECT to assign a value to a SQL variable. The one we will highlight today is what occurs when the result set of the SELECT is empty.
Category Archives: SQL
Querying Over Multiple Child Collections With NHibernate
Typically with NHibernate, I’m always querying over one table and eager fetching it’s child collections. I’m also only performing WHERE conditions on that initial table I am querying over.
The other day though, I needed to solve a problem where I was adding WHERE conditions to the child collections. Now in SQL, this is quite easy but in NHibernate, it took me a while to figure out how to do this efficiently.
T-SQL – Easy Cursor Optimization by Defining Attributes
When creating lengthy T-SQL queries, sometimes a set-based approach just doesn’t cut it.
So when you find yourself going with a procedural-based approach and using a Cursor like a foreach loop, be sure to check out the the available attributes for Cursors to boost performance.
Explicitly Specifying the Identity Column Value using Fluent NHibernate
I recently ran into a situation where I was saving to a database table that did not have an auto-incrementing identity column. I didn’t realize that at the time when I was setting up my NHibernate mapping and it caused me a headache for about half an hour attempting to figure out what was causing the problem.