Sql-server – Error on creating database in SSMS

sql serversql-server-2008ssms

I am using SQL Server Management Studio 2008. I am connect to localhost and I want to create a database. When I click on New Database, type the name and click ok, I get the message:

Index was outside the bounds of the array (Microsoft.SQLServer.Smo).

Best Answer

Perhaps you have Management Studio 2008 and your localhost is a newer version. If this is the case, you should always use the most recent version of Management Studio even if you sometimes manage lower versions. You can determine the version of the engine you're managing by looking at the top-level node in Management Studio's Object Explorer - 2008 is going to show 10.0.xxxx, 2008 R2 is going to show 10.50.xxxx, and 2012 is going to show 11.0.xxxx. You can tell what version of the client tools you have by going to Help > About.

Another possibility is that you are still using the RTM version of Management Studio 2008. If this is the case, you should apply SP3 (if you are in fact on 2008) or apply SP2 (if you are on 2008 R2, which a lot of people confuse with 2008).

Your best bet, IMHO, is going to be to uninstall the 2008 client tools entirely and install Management Studio 2012 (in SP1, the client tools are now free and fully functional). Not only does it have far fewer bugs like this, and plenty more features, but you won't have to do this later when you have to manage your first 2012 instance (which the 2008 tools aren't going to be very good at).

In the meantime, instead of using the UI as a crutch to create a database, you could learn the DDL and perform this in a query window, which won't have any problems:

CREATE DATABASE MyNewDatabaseName;

You can learn more about the CREATE DATABASE syntax in Books Online.