title: Pass a .sql file to SQL Server for execution
body: <p>I have an application that generates sql insert AND update statements in an offline/disconnected manner such that each query that I would normally run is simply written to a txt file. I do this so that the application can continue to run from any server without latency and will continue to work even if the database were to become unavailable.</p>
  
  <p>At some point, I'd like my c# app to pass this file of queries to SQL Server to be executed so all the pending inserts and updates can be performed. Ideally the list of updates/inserts would happen in a transaction so I can see that it finished and delete the local txt file so I don't attempt to run it again. </p>
  
  <p>What's the best way to accomplish this? FTP the file to the server and then what? Or should I just open a connection to the db and run the entire thing as one giant query (CommandText)? My concern is that the file could be 10, 20 or 50 megabytes so I'm looking for something more robust than passing t-sql over a SqlCommand. Any ideas?</p>