Earlier, I wrote about how I installed SQL Server 2016 on my machine. In this article, I talk about creating and populating a baseball database.
I am a huge baseball fan. I started following the New York Yankees when I was about 12. (In an act that is likely anathema to religious fanatics, I married a Boston Red Sox fan; during baseball season, one of us — metaphorically speaking — ends up sleeping on the couch!) I have been known to schedule vacations around Major League Baseball schedules. I believe that Cooperstown is Mecca.
Why, you might ask, is this relevant to installing SQL Server? Because I believe that one of the best ways to learn something is to have fun while you’re doing it. So in this implementation, instead of installing NorthWind Traders or AdventureWorks (the standard practice databases used by SQL Server enthusiasts everywhere), I will instead install a copy of Sean Lahman’s baseball database. (At the time of this article, the most recent version goes to and includes the 2015 baseball season.)
I should note that this isn’t to say NorthWind or AdventureWorks isn’t fun; rather, baseball is something about which I’m passionate, and is more likely to keep my attention. At some point, I’ll likely install NorthWind or AdventureWorks as well, as many SQL references and guides refer to them.
I downloaded the most recent SQL version from Sean Lahman’s website, which left me with a .ZIP file. Inside the file, I found a MSSQLMASTER.SQL file (you’ll find it in \mysql core\core\) that I extracted from the .ZIP file. I opened the file with SSMS.
The first thing I noticed was that it created a database called “stats.” I did not want to use this as my database name, so I first replaced all instances of “stats’ with “baseball”. Once this was done, I ran the database build query.
Unfortunately, it would not be that easy. The query file is very large. When I ran the query, I received the following message.
Okay. It has a lot of rows to insert (the data includes over a hundred years of statistics, after all). Instead, I opted for just creating the database and tables. However, even that proved to be problematic.
“Okay,” I said to myself, “what’s going on now?”
First, I had a permission issue to deal with (this doesn’t appear in the above log; I neglected to include that message). I looked for the C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA folder. When I tried to open it, I got a message saying that I had insufficient permissions to open it. “What?” I said, “this is my own machine, and I’m the administrator!” However, it also prompted me asking whether I wanted to open it. I answered yes. Once I did, I tried running the query again, and the permission error seemed to disappear.
However, that’s when I got the errors shown above.
That’s when I noticed that the filename references MSSQL11. My database path includes MSSQL13. Okay. I changed the path in the filename from MSSQL11 to MSSQL13 and reran the query. This time, it ran successfully.
I did notice one thing about the table infrastructure. All columns were defined as NULL, which indicated to me that there were no unique indices or primary keys defined. All tables would be heaps. That’s something that I’d need to fix, but that was likely another project for another time. For now, I was more concerned about building the database infrastructure and inserting the data.
Once my database and tables were built, I commented out the CREATE DATABASE and CREATE TABLE lines from the code, leaving only the INSERT commands. Just for grins, I tried running the query again, and once again got the “insufficient memory” message. Okay, no dice. How was I going to get around this? I suppose I could’ve selected and run the INSERT queries piecemeal, but that was going to be a long and painful process.
sqlcmd -d baseball -i Downloads\mssqlmaster.sql
Here’s what I got:
sqlcmd: Error: Connection failure. SQL Native Client is not installed correctly. To correct this, run SQL Server Setup.
Interesting. I went to look up SQL Server 2016 Native Client, and found this. So SQL Server 2016 does not include Native Client. So, I tried to download and install Native Client.
Of course, nothing ever goes as planned. I got this message.
So, I went into my Settings to check my Native Client. It told me that 2012 Native Client was already installed.
After Google-searching my error messages, I realized that I had SQL Server 2008 Express installed, and my SQLCMD was likely getting confused between versions. That was likely the culprit. So I went ahead and uninstalled SQL Server 2008, and tried my SQLCMD command line again. This time, the SQLCMD did not give me any errors, and my command prompt started scrolling with the familiar “(1 rows affected)” message that appears when SQL Server inserts rows into tables. The script finished without any problem.
Once the script finished, I ran a query to see if my data had made it into the tables.
So it appears that we are good to go! Our baseball database is populated!
I now have a baseball database with which I can play to my heart’s content. I’ll be using this to practice my SQL skills — and ‘blog about my adventures (or misadventures, as the case may be) as I do so.