August 8, 2012 at 1:20 pm
what is the Best way to run huge script on production server ? (code drops)
The script has several alter procedures to run against production server.
Do I need to execute the entire script at once or need to execute each alter procedure one by one.
Please suggest a best way to do this task...
Thanks
August 8, 2012 at 2:09 pm
I would suggest a single script with a go between each batch. It is far less prone to error than using a whole bunch of files and trying to remember which one(s) you have already executed. Just make sure that your scripts are able to run more than once without causing any issues.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 10, 2012 at 9:17 am
If you are running ALTER statements or drop and creates it might be more manageable to run each one as a separate script..perhaps using sqlcmd. You can then output to a file and capture any errors
Just a thought
Graeme
August 10, 2012 at 10:02 am
August 12, 2012 at 12:38 am
A better practice is to print out the result of each alter statement and pipe all output into a log, so easy to find out which procedure is causing error if any.
August 12, 2012 at 6:54 am
nagkarjun1 (8/8/2012)
what is the Best way to run huge script on production server ? (code drops)The script has several alter procedures to run against production server.
Do I need to execute the entire script at once or need to execute each alter procedure one by one.
Please suggest a best way to do this task...
Thanks
Do they all have to go or none go? Also, step 1 for this should be to make a backup of the database or at least the original stored procedures especially if you're not managing revision control with something like SVN.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 12, 2012 at 1:17 pm
I have to second Jeff's sentiment. You should also be using some kind of version control on the code. Whatever tool you're comfortable with is fine. I like to be tool agnostic so whatever works best for you.
August 13, 2012 at 2:44 am
i would suggest using Redgate's SQL Compare, its a great tool especially for this scenario where you need to run a batch of alter scripts. If you dont have this tool now, i would suggest running the alter scripts one by one so you would know which one is successful and which one failed.
August 14, 2012 at 9:23 am
Carlaabanes (8/13/2012)
i would suggest using Redgate's SQL Compare, its a great tool especially for this scenario where you need to run a batch of alter scripts. If you dont have this tool now, i would suggest running the alter scripts one by one so you would know which one is successful and which one failed.
If the script is already written, what difference does this make? You are also assuming that the script is all from 1 database and that all changes are needed. Don't get me wrong... SQL Compare is a really useful tool. However, if you already have a script or have been compiling one based on approved changes, what benefit does it give you?
Jared
CE - Microsoft
August 15, 2012 at 10:11 pm
If you have a single script ready you may just run it from Command Shell using sqlcmd tool (2008 replacement for osql)
If you actually have a bunch of scripts you may run them all using a loop:
FOR /F "delims=" %%i IN ('DIR /A-D /b /ON *.sql') DO (
sqlcmd -U UserName -P Password -S Servername -d Database -i "%%i" -I
)
Make sure that your scripts are numbered in the same order as you want them to be executed.
_____________
Code for TallyGenerator
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply