Creating a Neural Network in SQL Server

When I want to create a neural network, my usual approach is to write a custom C# program from scratch. I decided to investigate whether or not it’s possible to create a neural network in Microsoft SQL Server. The answer is, yes, it’s possible, but the process is rather clunky.


I found very little documentation about neural networks in SQL Server. It turns out that to create a NN that accesses a SQL Server database, you must use the Visual Studio developer tool, even though you don’t have to write code. The first steps were to set up the necessary tools by installing the SQL Server Data Tools (SSDT) library for Visual Studio (2013). This, by itself, was quite an adventure, and I don’t mean in a good way. Next I had to install SQL Server Business Intelligence project templates for Visual Studio 2013. Another process that involved several errors and took a long time.

I decided to create a neural network model for the famous Iris Data set where the goal is to predict species from petal length and width and sepal (a leaf-like structure) length and width. I downloaded the data set as a text file. I created a SQL database and table to hold the data. Only later did I find out that to work with NNs in SQL Server, you must have a key column. So I added an empty, first dummy column to the text file, and added an IDENTITY column to the table definition. I inserted the data from the file into the table using the BULK INSERT command.


Again, only many errors later did I discover that the only way I could get neural networks to work was to use an explicit Windows user rather than trusted authentication to connect. So, after I created and populated the iris flower database, I associated the DB to my network user name and password.

Once the DB was created and the prerequisites were installed, I launched VS and created a new “Analysis Services Multidimensional and Data Mining Project”. The template generated a lot of code. Briefly there are four meta-steps. First, create a new Data Source. Second, create a new Data Source View. Third, create a new Mining Structure. Fourth, create a new Mining Model. Each of these steps has multiple sub-steps. The images here represent only about 1/5 of the overall process.






After much trial and error, with the emphasis on error, I finally created a neural network model from SQL Server data. I have three main criticisms. The documentation is awful. There is too much work involved in installing the prerequisites. The resulting NN model is difficult to use. My conclusion is that for my scenarios it’s preferable to read SQL data into a dedicated neural network system rather than to create a neural network in SQL Server.

This entry was posted in Machine Learning. Bookmark the permalink.