We have a View in Azure SQL server that is erroring - but only when utilizing TOP.
SELECT * FROM View
= fine.SELECT [list every column individually] FROM View
= fine- Take the underling code from the View and run it = fine.
It's just including TOP (anything) that causes the ERROR. Even SELECT TOP (1) * FROM View
- repeatedly errors.
(It's not that everyone on my team simultaneously forgot the syntax for TOP - plus it does it when selecting SELECT TOP 1000...
via the SSMS interface as well).
The specific error is:
Msg 537, Level 16, State 3, Line 1. Invalid length parameter passed to the LEFT or SUBSTRING function.
Which, sure - that's a likely error given the query: There are things being split by a delimiter, but one needs to remove the entries that lack that delimiter, in the WHERE clause.
But why is it only throwing this when using TOP? I'm kind of at a loss.