I get an error on executing the script and I am ot able to find it. I was looking for this kind of script and now I am not able to use it because of the error.
Msg 245, Level 16, State 1, Line 59
Conversion failed when converting the nvarchar value 'usp_GetListOwner_AZ00' to data type int.
Please help me fix this.
I too came to the end of this discussion to find the answer to the above quandary. Reread the article and found I missed an assumption. Posting in case someone else did too.
Assumptions and Prerequisites
If you want your scripts to automatically execute in a pre-defined order, the easiest method is to ensure the file names reflect the order of execution. For example, if you have three script files, ScriptA.sql, ScriptB.sql and ScriptC.sql, you would want to name them as
Thanks for the script Sadequl Hussain.
Out of curiosity about half way through the discussion there was a post on using PoSH for this. It seems to be incomplete in that there are no parms and the output txt files show up as 0 byte empty files. If anyone is feeling generous I am looking for a way to do what this SQL script does in PowerShell, complete with error/success tracking. I have modified this SQL script for a SPROC with parms but I don't know PoSH yet. Currently xp_cmdshell is enabled on all servers in my environment but that may not always be true.