{"id":216,"date":"2012-05-17T05:56:19","date_gmt":"2012-05-17T05:56:19","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/05\/17\/a-top-n-value-may-not-be-negative\/"},"modified":"2012-05-17T05:56:19","modified_gmt":"2012-05-17T05:56:19","slug":"a-top-n-value-may-not-be-negative","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/05\/17\/a-top-n-value-may-not-be-negative\/","title":{"rendered":"A TOP N value may not be negative"},"content":{"rendered":"

Error Message:
\n
\nMsg 127, Level 15, State 1, Line 1
\nA TOP N value may not be negative.
\n<\/font> <\/p>\n

This error occurs when you try to specify negative value for the TOP Clause in the select statement.<\/p>\n

Simple Example:
\n[sql]
\nSELECT TOP(-5) * FROM sys.tables
\n[\/sql]<\/p>\n

When the above code is executed error message 127 would occur.<\/p>\n

Fix\/Resolution:<\/strong><\/p>\n

Update the TOP clause with a positive value.
\n[sql]
\nSELECT TOP(5) * FROM sys.tables
\n[\/sql]<\/p>\n

In the above code -5 is changed to 5.<\/p>\n","protected":false},"excerpt":{"rendered":"

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…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1991,128,1992],"tags":[1993,1994],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/216"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=216"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/216\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}