Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqldba20
Posting Yak Master
183 Posts |
Posted - 2007-05-07 : 12:53:27
|
| Folks:I have a text file which has all "drop" statements (drop proc, drop view)... I want to run this statements on a daily basis. How can I automate this? Thanks ! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-07 : 13:03:12
|
| You can create a SQL Server job that runs your script. Jobs allow you to run things on a scheduled basis. Check out SQL Server Agent in Enterprise Manager or Management Studio.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-07 : 13:23:33
|
seems to me like a dangerous kind of script to be running from an agent job...you sure you want all your objects to be dropped automatically? www.elsasoft.org |
 |
|
|
sqldba20
Posting Yak Master
183 Posts |
Posted - 2007-05-07 : 13:25:35
|
| The text file with the "drop" statements will be generated by a program and the drop statments will be changed on a daily basis. I would like to execute that text file and I am not sure how I can automate it . What I am doing now is, copying the contents in the file (drop statements) and then running it from Query Analyser. Thanks ! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-07 : 13:28:57
|
| sqldba20, did you see my post? To automate things inside SQL Server, you setup jobs in SQL Server Agent.And I agree with jezemine about this being a bad thing.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-07 : 13:31:17
|
even more reason not to automate this. if the script is generated, don't you think you should review it for correctness before executing it? Otherwise if there's ever a bug, the wrong objects could be dropped and you'll have people knocking on your door wondering what happened to their data. www.elsasoft.org |
 |
|
|
pootle_flump
1064 Posts |
Posted - 2007-05-07 : 13:54:55
|
| Is the program that is generating the drop script also creating the objects on the fly? |
 |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-05-07 : 14:00:32
|
| You can use osql utility to execute commands from a file. Look into the help for osql and jobs. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|