Imply bit with constant 1 or 0 in SQL Server -


Is it possible to express a bit to 1 or 0 if used as a field value in a certain statement?

For example

In this case the statement (which is part of a selection statement) is of the ICourseBased type int.

  case when FC  

To get it as a bit of type I have to put both values ​​in. The case ends when FC.CourseId is not zero (as 1 bit) as other artists (in the form of 0 bit) IsCoursedBased

Is there a small hand of expressing values ​​as a bit type without being cast every time?

(I'm using MS SQL Server 2005)

  Cast F.C.Course ID is not empty, then in the form of 1 and 0 bit bit)  

CAST space is "CAST (Expression AS Type)". In this context, the case is an expression .

If you have many types of expressions, then I will declare Bit Wars @true and @false and use them I or use UDF if you really want ...

  DECLARE @Treue bit, @false bit; SELECT @Treue = 1, @ False = 0; - can be combined with selection in SQL 2008 SELECT case when FC.CourseId is not zero then @TRUE ELSE @ False END AS ...  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -