How to select true false based on column value in sql server?



How to select true false based on column value in sql server?..

Answer / Narendra Pal Singh

In SQL Server, you can use the CASE statement to create conditional logic that returns a true or false (1 or 0). Here's an example:nn```sqlnSELECT ColumnNamenFROM YourTablenWHERE CASE WHEN ColumnValue = 'desired_value' THEN 1 ELSE 0 END = 1;```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

How can I create a new template for import ? : sql server management studio

1 Answers  


if a parameter is not send to a stored procedure what type of identifier is to be used in Stp and if that parameter is not feed to the a query inside the Stp how to validate with out useing IF condition

1 Answers   Aviva,


How can i change the column name.

13 Answers   HCL, Yardi Software,


How does clustered and non clustered index work?

1 Answers  


How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?

1 Answers  


What is the use of nvl work?

1 Answers  


Explain about service Broker functions?

1 Answers  


What do you understand by intent locks?

1 Answers  


What is a mutating table error and how can you get around it?

1 Answers  


optimization techinques

1 Answers   Wipro,


What is the security model used in sql server 2005?

1 Answers  


In the primary key have a multiple field or not?

8 Answers   TCS,


Categories