SQL Server Database Diagram Index was Outside the Bounds of the Array
By: Sergey Gigoyan | Updated: 2020-03-13 | Comments (1) | Related: More > SQL Server Management Studio
Database diagrams can be very useful in terms of visually understanding the SQL Server database structure. It is possible to create a diagram for the whole database as well as for specific tables of the database. This illustration can be very helpful in easily understanding the table’s structure of the database and their relationships.
Creating a diagram is possible in SQL Server Management Studio (SSMS) prior to version 17. In the case of creating a diagram in version 17 of SSMS the following error message is received:
This is because in version 17, in spite of having the "Database Diagram" option under each database, it was actually removed and Microsoft considered it as a depreciated feature. This feature, however, is very useful for many developers and administrators and its absence can be quite uncomfortable. While it is possible to use many third-party tools to create database diagrams, we probably all agree that it is easier to have this feature integrated into SSMS.
Using older versions of SSMS will also solve the problem. Nevertheless, what if we want to use newer versions of SSMS with the "Database Diagram" feature?
Fortunately, despite expectations, the "Database Diagrams" feature is available with SSMS 18.1 and later. Thus, if we are using SSMS 17 thru 18.0, we can just upgrade to 18.1 and newer versions and have this feature available again.
We will illustrate this process step-by-step, but before that let’s see the problem in practice.
For instance, assume we need to create a database diagram for our sample TestDB database. In SSMS, we locate "Database Diagrams" just under the database, right-click on it and choose "New Database Diagram":
After that, we will receive the following error message:
Now, let’s check the version of SSMS.
To do that, go to Help > About:
The version is 17.8.1:
Update SSMS to Version 18.1 or later to solve database diagram error message
Let’s update SSMS.
To do so, close SSMS and follow this link to download the latest version.
At the time of writing this tip, the latest version of SSMS is 18.4 as shown below:
Click the download link and after downloading, locate the EXE file and double-click on it to install:
After that, click on "Install" to start the installation (you can change the location by clicking "Change" and choosing the desired location):
After installation, a restart is needed, so click "Restart":
When the computer is restarted, we can search for the new version of SQL Server Management Studio by typing ssms:
As we can see above, version 18 is installed, but the version 17 is still available. Hence, installing the version 18 does not override version 18. If we do not need the older version, we can just uninstall it.
Let’s start version 18 by clicking on it. As we are using it for the first time, we are asked whether to import settings from SSMS 17 or not. We will click "Import from SSMS 17" to import:
We can see that the SSMS version is 18.4:
Create Database Diagram
If in this new version of SSMS we click on "New Database Diagram", a window for creating a new diagram will be successfully opened. We can choose tables which will be added into the diagram (we have chosen both tables in our database) by clicking "Add":
Now we can see our tables structures and their references in our diagram:
We choose a name for the diagram and click the "Save" button. Now, it is stored permanently.
The diagram can be found under "Database Diagrams":
In conclusion, although creating a database diagram is a quite useful feature among many developers and DBAs, it is unavailable in the version 17 of SSMS. In newer versions of SSMS, however, this feature is available again. Thus, we have fixed the problem of creating a database diagram in SSMS 17 by upgrading it to SSMS 18.4.
To find more information about the discussed topic, please follow the links below:
Last Updated: 2020-03-13
About the author
View all my tips