Project Description
A simple ASP.NET page that allows executing any T-SQL scripts. The ExecuteSQL page can be used when the ASP.NET application is working with a database, but the database is not available outside of the ASP.NET application. The ExecuteSQL page can be temporarily embedded into the ASP.NET application and allows executing any T-SQL scripts.


Project Origin
I created this simple tool when working on a blog post on using LocalDB under IIS. I needed to create a database and populate tables in a LocalDB instance that could only be accessed by the IIS Application Pool process.

This Tool Is Not Meant For Production Use!
This is a simple tool that can be useful during the development, but is by no means production quality. On top of that it is basically one big SQL-injection vulnerability (one can argue that SQL-injection is its main feature), so the ExecuteSQL.aspx page should be removed from your application whenever you're not using it!

  1. Copy ExecuteSQL.aspx and ExecuteSQL.aspx.cs to wherever you want to have it in your Web Application
  2. If using a server different than the automatic LocalDB instance ("Server=(localdb)\v11.0") change the DefaultServer value to your target server address
  3. Run the Web Application and navigate to ExecuteSQL.aspx page
  4. Select the database you want to work with from the "Database:" drop-down, type your T-SQL to the upper text box, and click the "Execute!" button
    • The results will appear in the lower text box

Last edited Dec 13, 2011 at 7:11 AM by kozielczyk, version 11