IIF Command in SQL Server

There is no “IIF” function in SQLSERVER as of VB and Access.

For example, say you had a table like this:

 StudID	Subject		Marks------	------		------1	Maths		801	Physics		751	Chemistry	601	English		45

Use the “Case” Command in SQLServer:

 --//////////////////////////////SELECT StudID,Subject,Marks,Status =  CASE  WHEN Marks > 50 THEN "Passed"  ELSE "Failed"  ENDfrom tblMarks--//////////////////////////////StudID	Subject		Marks 		Status------	------		------		--------1	Maths		80		Passed1	Physics		75		Passed1	Chemistry	60		Passed1	English		45		Failed
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: