How many times have you had to create a comma delimited list from a table column? Do you ever remember how to do it? I don’t. Here is a little snippet I find useful: -- this will be a comma delimited list of location ids DECLARE @LocationIds Varchar(Max…
The other day we needed to write a report on online sales for the last week. SQL doesn’t offer developers many predefined functions to work with date ranges unlike the C# programming language. Here is a little example how to query SQL for some data between the dates for…
We use enums quite extensively in our application as they are great for representing integral values in a strongly typed way using symbolic names eg. if (Status == UserStatus.NotLoggedInAYear) ArchiveRecord(); is a lot more clearer and meaningful making it easier to maintain than if (Status == 3) ArchiveRecord() The enum names…
“Object reference not set to an instance of an object” is probably the most common run-time exception message spat-out by the .Net framework, and most programmers will probably encounter this more often than any other framework exception type. This exception, or more specifically a “System.NullReferenceException” is always caused when…
As a .NET programmer most of my time is spent coding in C# and I try to avoid writing SQL where possible, which is great as we have dba's that can help with the more complicated queries. Why is it so complicated to write a loop without turning the database…