Posted in .Net Basics, Database, SQL Server

Database Performance Tips

As a developer, you may or may not need to go into the database and write queries, or design tables and indexes, or help determine configuration of your SQL Server systems. But if you do, these tips should help to make that a more pain free process.

ORM Tips:-

More and more people are using Object to Relational Mapping (ORM) tools to jump the divide between application code that is object oriented and a database that stores information in a relational manner. These tools are excellent and radically improve development speed, but there are a few ‘gotchas’ to know about Continue reading “Database Performance Tips”

Posted in C# 4.0, SQL Server

SQL Server Tips – Find # of business days between two dates

To find the business days or say working days between two dates. This could be the easiest task for many but I would still like to make a not of this, so I am writing this post.

DECLARE @IsSaturWorking bit
SET @StartDate ='2011/07/01'
SET @EndDate ='2011/07/31'

SELECT  (DATEDIFF(dd, @StartDate, @EndDate)+ 1)  -
 (DATEDIFF(wk, @StartDate, @EndDate)* 2)  -
        (CASEWHENDATENAME(dw, @StartDate)='Sunday'THEN 1 ELSE 0 END)-
        (CASEWHENDATENAME(dw, @EndDate)='Saturday'THEN 1 ELSE 0 END)

I hope this help someone.