How to Use Default Parameters in User Defined Functions in SQL Server 2005

Yesterday I had to add a much needed parameter to a SQL Server 2005 user-defined function (or UDF). The catch was that the current version of the UDF (i.e. the version without the parameter) was already being used in production by a few SQL queries. Not wanting to break those existing queries, I decided to assign a sensible default value to the new parameter. With a default value I figured I could add the parameter to the UDF without having to modify existing calls to the UDF.

Boy was I wrong. Continue reading » How to Use Default Parameters in User Defined Functions in SQL Server 2005




SQL Server Case Sensitive Queries With Case Insensitive Collation

I’m sure that every SQL Server developer has had the experience of waking up at 3:00 AM, in a cold sweat, wondering “How can I execute a case sensitive query when my server uses a case insensitive collation?”
Continue reading » SQL Server Case Sensitive Queries With Case Insensitive Collation