This article[
^] explains how you can connect Javascript with Sql Server.
Based on the connection string described here, you will be able to connect to Sql Server.
However, this is not a recommended practice for many reasons. Use a server side language like .Net or PHP to execute code that inserts into a Sql database.