0

Index was outside the bounds of the array

While it may seem to be answered already, I have found only the solutions like "install the new SSMS", or new patch to SQL Server 2008...

I my case, I am using SQL Server 2014 installed on Azure (12.0.2000), and SQL Server Management Studio v18.6 (15.0.18338.0) installed at the related virtual machine with Windows Server 2019 Datacenter.

The query worked at the same SQL Server on-premises, even though is a bit newer (12.0.6118.4).

Another difference may come from differences when querying 3rd party database. That is, on-premise the query uses 3-part name of the table, on Azure the query 2-part name of the external table.

One more detail: the query (Microsoft Dynamics Nav database) may be somehow specific. It uses the self-join of the Customer database like this (simplified).

SELECT [the selection of columns]
FROM dbo.[company$Customer] AS cu
LEFT OUTER JOIN dbo.[company$Customer] AS cu_billto
             ON cu.[Bill-to Customer No_] != ''
             AND cu_billto.No_ = cu.[Bill-to Customer No_]
WHERE cu.timestamp > @max_ts     -- only the modified records
   OR cu_billto.timestamp > @max_ts  -- or with modified bill-to record

The @max_ts is of binary(8) type, and it is the maximum rowversion value from the previous run.

Is it a well-known problem? Would the new build of the SQL Server fix the error? (I cannot do that on my own. I have to ask someone else to do that, and I want to be sure whether it is necessary.) Any other idea?

pepr
  • 20,112
  • 15
  • 76
  • 139
  • In the select list (which you've excluded) are you doing any string operations? LEFT, RIGHT, etc etc? – simon at rcl Oct 26 '20 at 14:10
  • No. Actually, I have simplified to the single column (`cu.No_`) and it still shows the same error. I am going to add more information as update (in a minute). – pepr Oct 26 '20 at 14:16
  • See: [Why should I provide an MCRE for what seems to me to be a very simple SQL query?](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-a-minimal-reproducible-example-for-a-very-simple-sql-query) – Strawberry Oct 26 '20 at 14:40
  • If you suspect the error is in SSMS (rather than sql server itself), you can try to execute the query in a different way. – HoneyBadger Oct 26 '20 at 14:42
  • @HoneyBadger: Yes, the error is reported when I tried the query in SSMS. However, it was first reported when the query was executed by a web application (IIS) and logged into my application log. So, it is or related also to SQL, or to IIS. – pepr Oct 27 '20 at 12:29
  • What is @max_ts_firmy defined as and what value does it hold? – simon at rcl Oct 27 '20 at 16:59
  • @simonatrcl: Oh, sorry. I have updated the text... The `@max_ts` is of `binary(8)` type, and it is the maximum `rowversion` value from the previous run. – pepr Oct 29 '20 at 15:42

0 Answers0