A TOP N value may not be negative

Posted on : 17-05-2012 | By : Devi Prasad | In : Msg 127, SQL Errors, TOP Clause

Share:

0


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:

SELECT TOP(-5) * FROM sys.tables

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

Fix/Resolution:

Update the TOP clause with a positive value.

SELECT TOP(5) * FROM sys.tables

In the above code -5 is changed to 5.

(Visited 309 times, 1 visits today)



References : Devi Prasad (sqlserverlearner.com)

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.


Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.




Write a comment



Tags: ,