Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««45678

A Simple way of Automating Scripts Expand / Collapse
Author
Message
Posted Wednesday, February 15, 2012 7:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, October 29, 2012 11:26 PM
Points: 1, Visits: 16
Sadiq,

could you let me know where to put the database name on which I am running the scripts, also will it work on SQL 2008?
Post #1252469
Posted Wednesday, March 7, 2012 4:56 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, June 24, 2013 9:19 PM
Points: 11, Visits: 78
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.

Thank you
Post #1263360
Posted Tuesday, November 12, 2013 1:00 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, July 11, 2014 3:16 PM
Points: 18, Visits: 103
pamalatha (3/7/2012)
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.

Thank you


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

1.ScriptA.sql
2.ScriptB.sql and
3.ScriptC.sql

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.

TIA
Post #1513608
« Prev Topic | Next Topic »

Add to briefcase «««45678

Permissions Expand / Collapse