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


Automating .sql Scripts


Automating .sql Scripts

Author
Message
clasley 57551
clasley 57551
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 11
I am in a bit of a jam. I am using SQL Express 2008 on my PC. I am new to this but I am creating a new database off of several processes within Server 08. I have everything running through Stored Procedures and I created a .sql script that Executes each of the stored procedures in order. I know if I had SSIS I could have the package run overnight, but my company does not support SSIS on SQL Express machines. Is there any other way to have SQL Server automatically execute my .sql file overnight, while I am away and my computer is locked? I am a novice SQL Server user.
keith.gerritsen
keith.gerritsen
SSC Veteran
SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)SSC Veteran (237 reputation)

Group: General Forum Members
Points: 237 Visits: 366
It semes SQL Express installs a disabled SQL Server Agent, so my initial suggestion of putting your T-SQL script into an agent job T-SQL step won't work (homework assignment: search more exhaustively than I am able to if there is a way to start the Agent for Express edition)

However, you could write an application as simple as a form with a button, that opens an ODBC connection to your database, and runs your stored procedures.
LutzM
LutzM
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24061 Visits: 13559
I would use a Windows scheduled task with the related sqlcmd.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
subbu_e
subbu_e
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1537 Visits: 173
i used to do this by creating batch file using sqlcmd and will schedule it in the windows scheduler

Regards,
Subbu
Click here to Get Speedy answer or solution
clasley 57551
clasley 57551
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 11
I will look into this. I think you are on to something. Thanks
clasley 57551
clasley 57551
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 11
I looked into the Windows scheduler, all it would so was open the .sql file but it did not actually execute it.
grahamc
grahamc
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1494 Visits: 1039
Use the Windows Scheduler to execute a SQLCMD command and point the SQLCMD to .sql file. There are other connection details that SQLCMD will require, but this is how I used to do this at a previous place.
clasley 57551
clasley 57551
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 11
I will definitely take a look at the sqlcmd today, thank you all so much.
grahamc
grahamc
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1494 Visits: 1039
Rather simple, but BOL is a good source for examples, syntax, etc. Good luck and let us know how it goes :-)
clasley 57551
clasley 57551
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 11
OK, I was able to schedule a sqlcmd. Got that part figured out. It runs and closes in about 15 seconds. But I did not notice any change in the actual database. I have a field that captures the time when the script is done running. When I execute the script manually it takes about 45 minutes for the process to complete. I did not get any error message from the SQLCMD. Any ideas, what I am doing wrong?

Here's what my SQL Cmd looks like
sqlcmd -S .instancename\SQLExpress -i"C:\Documents and Settings\locationexample\ProcessCreateCommercialCatalyst.sql "
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