Msg 127 Level 15 State 1 Line 1 – SQLSERVERLEARNER https://sqlserverlearner.com LEARN SQL SERVER ONLINE Thu, 17 May 2012 05:56:19 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 A TOP N value may not be negative https://sqlserverlearner.com/2012/05/17/a-top-n-value-may-not-be-negative/ https://sqlserverlearner.com/2012/05/17/a-top-n-value-may-not-be-negative/#respond Thu, 17 May 2012 05:56:19 +0000 https://sqlserverlearner.azurewebsites.net/2012/05/17/a-top-n-value-may-not-be-negative/ Error Message:

Msg 127, Level 15, State 1, Line 1
A TOP N value may not be negative.

This error occurs when you try to specify negative value for the TOP Clause in the select statement.

Simple Example:
[sql]
SELECT TOP(-5) * FROM sys.tables
[/sql]

When the above code is executed error message 127 would occur.

Fix/Resolution:

Update the TOP clause with a positive value.
[sql]
SELECT TOP(5) * FROM sys.tables
[/sql]

In the above code -5 is changed to 5.

]]>
https://sqlserverlearner.com/2012/05/17/a-top-n-value-may-not-be-negative/feed/ 0