Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


GREATER function in MS SQL

Posted on 2006-03-27
Medium Priority
Last Modified: 2008-02-26

Is there a function in MS SQL that returns the greater value of 2 expressions, like GREATER(exp1,exp2) in Sybase?

Question by:BlueAlien
LVL 43

Expert Comment

ID: 16299470
Hi BlueAlien,

No but you can use the case construct:

Select Case When ValueA>ValueB Then ValueA Else ValueB End As GreatestValue

Tim Cottee
LVL 44

Accepted Solution

Arthur_Wood earned 200 total points
ID: 16299531
You can also create a User Defined Function (UDF) in SQL Server which will carry out the same operation, and you could even name that UDF GREATER.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Exchange database can often fail to mount thereby halting the work of all users connected to it. Finding out why database isn’t mounting is crucial and getting the server back online. Stellar Phoenix Mailbox Exchange Recovery is a champion product t…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question