Tuesday, June 28, 2005

Avoiding "Case When" From your TSQL in MS-SQLServer

Today I was working on a query with a conditional construct where i had to use CASE WHEN. But a "Case when" will be evaluted for each record.
Keeping this thought was looking for a new logic. At last i arrived that

SELECT FirstName, LastName, Status
FROM RequestTable
Inner join
Select -1 as Appr , 'New' as Status
Select 0, 'Created'
Select 1, 'Accepted'
Select 2, 'Rejected'
) T

On IsNull(Cast(Approved as smallint),-1) = Appr


Anonymous said...

Create any type of website with the ease of use of a simple word processor!project management softwareproject management software

johneyprice5665921845 said...

I read over your blog, and i found it inquisitive, you may find My Blog interesting. So please Click Here To Read My Blog