SQL query use of CASE inside SELECT
02:16 28 Jun 2011

I have a SQL query:

select DateDiff(d,StartDate, EndDate) DaysEmployed from ClientDayActivity

I want this to become like this:

EmployDays = CASE WHEN NOT end_date IS NULL THEN
DATEDIFF(d,start_date, end_date) ELSE   
DATEDIFF(d,start_date, CONVERT(DATETIME, '" & Cstr(strEndDate) & "', 102)) END

I picked this query from old application and I have to use it according to my DB and application. I picked up this query from asp code, they had a string of query. As well as I am not getting what is this: '" & Cstr(strEndDate) & "'.

sql-server-2008 stored-procedures select case