-1

I have a sequence of scripts that I run on a daily basis that require some user input, changing this input in SQL Server each run is becoming tedious. Is it possible to write a program that will be able to take in this input and run the scripts? I use visual studio, but have not had much experience with scripting within an application.

Development is in C#

Example: SELECT * FROM table WHERE companyId = 1

I would like to have a text field in an application and when I select run it will put 1 or some other input where companyId = ?

Zach M.
  • 1,188
  • 7
  • 22
  • 46
  • 2
    The short answer is "yes". I have no idea what the longer answer is, because it isn't clear what you want to do or what programming language you're using. But [this question](http://stackoverflow.com/questions/650098/how-to-execute-an-sql-script-file-using-c-sharp) might give you a start. – Pondlife Apr 29 '13 at 19:27

1 Answers1

1

Well any SQL statement can be executed using osql command line and this (batch script) can be sheduled in windows scheduler so limiting yourself to windows an SQL scripts is no problem. Batch file can also take additonal parameters. If however you are running SQL above Express version the traditional answer is to create a maintenance job and schedule it as a maintenance task because you can get sucess and failure reports emailed to you for no extra work... But is its just windows scheduling http://windows.microsoft.com/en-GB/windows7/schedule-a-task (oh there are versions back to xp) or perhas powershell is your best bet: http://en.wikipedia.org/wiki/Windows_PowerShell: this has more power than you will ever need.

Ian P
  • 1,724
  • 1
  • 10
  • 12
  • How is this not a question when some one answered it? – Zach M. Apr 30 '13 at 02:47
  • 1
    Probably because its not strictly hard core programming, there are a few trolls around who take delight in voting down what they consider "not proper real" questions. However the learning curve is often steepest at this point. Its also the point where its most dificult to use the "right" language. Google is little help because if you type in yout tags, you'll get nowhere. They expect clear examples, what is your script going to do etc. Trivially any question that can be answered "yes" or "no" is a closed question. – Ian P Apr 30 '13 at 07:43
  • Couldn't have said it better myself, I asked this question after an 11 hour work day and could have explained more but I was extremely tired. But it's alright. – Zach M. Apr 30 '13 at 12:49