---
title: "SIGN function in SQL SERVER"  
description: "SIGN is an in-build function of Transact-SQL. This is a mathematical function that returns the positive (+1), zero (0), or negative (-1) sign of the s"  
author: "AVADHESH PATEL"  
published: 2012-09-12  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1001/sign-function-in-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# SIGN function in SQL SERVER

SIGN is an in-build function of Transact-SQL. This is a mathematical [function that returns](https://www.mindstick.com/forum/157562/what-is-a-function-in-sql-create-a-function-that-returns-stu_name-when-passed-stu_id) the positive (+1), zero (0), or negative (-1) sign of the specified expression.\

##### Syntax

SIGN ( numeric_expression )

##### Example

```
DECLARE @value int
SET @value = -1
WHILE @value < 2
   BEGIN
      SELECT SIGN(@value)AS 'RETURN VALUE'
      SELECT @value = @value + 1
   END
```

Screen Shot

![SIGN function in SQL SERVER](https://www.mindstick.com/mindstickarticle/cd446dc0-ea7d-44af-a493-dd62846ea51f/images/bdbc320d-3730-47ee-b795-3a401cbcbb95.png)

If data type is decimal

```
-- DATA TYPE DECIMAL
DECLARE @value DECIMAL(4,2)
SET @value = -1
WHILE @value < 2
   BEGIN
      SELECT SIGN(@value)AS 'RETURN VALUE'
      SELECT @value = @value + 1
   END
```

##### Screen Shot

![SIGN function in SQL SERVER](https://www.mindstick.com/mindstickarticle/cd446dc0-ea7d-44af-a493-dd62846ea51f/images/411cfbd6-0cc1-41da-8032-19561af33b77.png)

Here we [notice](https://yourviews.mindstick.com/story/4562/happy-independence-day-2024-things-to-notice) that when there is positive value the function gives positive [values](https://www.mindstick.com/forum/159360/how-to-write-sql-query-to-join-comma-separated-values) and if the values are negative it will return you negative values. Also we notice that if the data type is INT the [return value](https://www.mindstick.com/forum/33675/how-to-convert-return-value-of-abmulivaluecopylabelatindex-into-nsstring-in-ios) is INT and when the value passed to the function is Numeric the [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) also matches it. Not every data type is compatible with this function. Here is the quick look up of the return types.

1. bigint -> bigint

2. int/smallint/tinyint -> int

3. money/smallmoney -> money

4. numeric/[decimal](https://www.mindstick.com/forum/34709/please-write-a-program-for-decimal-to-binary-conversion-in-c-sharp) -> numeric/decimal

5. everybody else -> [float](https://www.mindstick.com/interview/34357/what-is-the-difference-between-decimal-and-float)

---

Original Source: https://www.mindstick.com/articles/1001/sign-function-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
