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”

Advertisements
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 @StartDate DATETIME
DECLARE @EndDate DATETIME
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.


	
Posted in SQL Server

SQL Server Tips – Find Stored Procedure or Function containing “Some Text”

Many times I came across a need to search procedure or functions having some “text”. The reason behind this need could be anything, here is the code to get that result. You need to query INFORMATION_SCHEMA.ROUTINES in order to get this details.  Continue reading “SQL Server Tips – Find Stored Procedure or Function containing “Some Text””

Posted in SQL Server

SQL Server Tips – Dynamic Order By

Many times we need to sort records based on some conditions and for that we need to implement conditional sorting in SQL server. I have mentioned some techniques to achieve this below.

Continue reading “SQL Server Tips – Dynamic Order By”