SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


A Simple way of Automating Scripts


A Simple way of Automating Scripts

Author
Message
siddhartha.datta
siddhartha.datta
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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?
pamalatha
pamalatha
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 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
mbrady
mbrady
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 134
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search