Running Batch Scripts
Jun 28, 2006
I've have been sent a large number scritps to update one of the databases i look after. Problem is there are hundreds of individal script files, all of which need to be run.
Is there a script / tool i could use, which would run all of the .sql files in a certain directory and update the database?
I can't seem to find anything built into SQL Server. Job schedular would seem to be the closest thing, but it would still require you select each script needed to be run.
Any ideas would be great.
Thanks
Cj
View 2 Replies
ADVERTISEMENT
Feb 28, 2002
Hi,
I'm trying to run a simple batch file from a SQL job (SQL 7.0 sp4). No errors are received but the job does not complete. When I try to run the job manually, I get a message stating "Error 22022: SQLServerAgent Error: Request to run job my_job (from User DomainAdminUser) refused because the job is already running from a request by Schedule 127 (Schedule 1).
The services are running as a domain admin account.
Help!
Thanks in advance.
View 1 Replies
View Related
Apr 6, 2001
I need to create a program that will run Client Access to download data from the AS400 to a flat file, then run SQL DTS to import the data into a table for use by another software package.
I've created a bat file that does that using the CA RTOPCB command and the SQL DTSRUN utility. Problem is that it appears that I need to first check to see if there is a table in SQL and if there is to delete it. Otherwise, rather than overlay the existing data in the table it adds to it.
Is there a way to issue a SQL drop table in DOS? Or am I missing something that could be done in SQL?
The DTSRUN is using a local package and CA is using a transaction request.
View 1 Replies
View Related
Mar 10, 2008
Hi
Is it possible using T-SQL to run a batch file located on different server, ie. PC1 has SQL Server on it, PC2 has the batchfile, I need to run the batchfile stored on PC2 on PC1.
Thanks
View 3 Replies
View Related
Mar 11, 2008
Hi
I am trying to run a batch file stored on different server from the one that SQL Server is on using T-SQL. I am using the following syntax:
EXEC master..XP_CMDShell '\hit1DEVArchivingArchivingDataFiles.zipdata.bat'
But it doesnt seem to be working, it states that it is not recognised as an internal or external command.
Any ideas?
Thanks
View 1 Replies
View Related
Jun 1, 1999
Exec master..xp_cmdshell "bcp sdnetpro..nbtorder11 out d:databtorder11.txt /c /t /Sservername /Usa /Ppassword"
Hi, this code run fine from within sql server query window. I want to put this code in a batch file and run the batch file.. it did not work. someone told me the revised code is :
bcp sdnetpro..nbtorder11 out d:databtorder11.txt /c /t,/r -Sservername -Usa -Ppassword"
This is not working. Please if anyone knows how to fix this, I would appreciate. One more thing, how can I confirm that the bcp has successfully done. do I have to create a log file and if so what is the code to create this log file.
thanks
Ali
View 1 Replies
View Related
Jul 1, 1999
I want to keep applications off of my database server so I have set up an application server (APPServer1). On APPServer1 I have a batch file that bcp’s data from DBServer1 into DBServer2 and is being passed the server name of DBServer2. On DBServer1 I have mapped a drive to the directory of APPServer1 and have created a task to run the batch job and pass the server name. So here’s my problem: when the scheduler runs the job, the bcp to DBServer2 fails, because it can not find DBServer2. When I execute the exact same command line in a DOS Box on DBServer1, the bcp works fine. I have verified that the server name is being passed correctly to the batch job in both methods.
Thanks in advance.
George
View 1 Replies
View Related
Mar 19, 2007
I have created a master controller package which runs as follows
deletes all the log files -> deletes few flat files on different drives -> preprocess task(execute package task) -> c# executable (execute process tasks) -> postprocess tasks (execute package tasks)
i need a create a task just before the preprocess task with an user input asking whether he wants to run a particular batch file before proceeding to preprocess. if the user says yes it should run a batch file followed by preprocess tasks, c# and post process or else it should directly goto preprocess, c# and post process (neglecting batch file task)
can anyone help me how to do it.
View 9 Replies
View Related
Mar 25, 2008
Hello,
I am looking for some way to run a sql query from a batch file on the SQL server. The query needs a user entered parameter, if that can be accomodated it would be great.
I read about some osql command & tried to run it but it kept saying "Server does not exist or access denied."
Please give me the steps to go about this.
Thanks,
-R
View 4 Replies
View Related
Jun 27, 2001
Is there a way to run/call a batch file from a stored procedure?
Or, is there a way to run/call a batch file from a trigger?
View 2 Replies
View Related
Sep 10, 2007
Hi,
I had created 2 packages... one is the parent package and contains a 50 iterations loop running a secondary package for each iteration... i had reached the following conclusion:
My package takes an average of 5 seconds from the time it ends executing one iteration and starts another... after about 30 iterations... my average time between end and start increases significantly to about 12 secs or even more...
All packages have delay validation set to false, and receive several variables from the parent package... Has for the logging, it is done to files based on a path coming from a variable in the parent package.
To execute the parent package i am using dtexecui.exe and i consider this behavior rather strange... had anyone experienced the same? Can anyone test this?
My environment is a 4 x64 processors with 8gb memory, so i guess its good enough to get 0 secs from end to start
I already consider the first 5 seconds weird...
Best Regards,
View 4 Replies
View Related
May 5, 2015
how to catch batch id from a running stored procedure. My intention is that when we run store procedures in batch we are running a lot of procedures and I would like to log each run and if the same procedure is running several times per day I need to separate the runs by a "batch id" for the specific run. I have created a logtable and a logprocedure that logs the start and end of a procedure run and also some values for the run. So I'm trying to find a way of fetching the "batch id" that the sp is running so I can separate the runs when analyzing the logtable. I have looked at metadata tables and also in the table sys.sysprocesses but I cannot find BATCH ID.
View 11 Replies
View Related
Jul 20, 2007
I've written a small dos batch script that runs a simple query throughosql and then calls an exe which sends an email if the returned value
Quote:
View 2 Replies
View Related
May 11, 2015
I have create a batch file to execute a stored proc to import data.
When I run it from the server (Remote Desktop) it works fine, but if I share the folder and try to run it from my pc, it doesn't do anything. I don't get an error, it just doesn't do anything. My windows user has admin rights in SQL. Why is it not executing from my PC?
View 9 Replies
View Related
Aug 7, 2007
HELP,
I need to take a variable from a tabel in SQL Server pass to a Batch file and execute the batch file. Right now I can exec the batch file with XP_CMDSHELL but how can I pass the variable to the batch file and loop through all the variables.
Please help
Phil
View 4 Replies
View Related
Dec 5, 2006
I am using the following batch file to execute a script that creates a db and all its objects in the local sql express:
sqlcmd -S (local)SQLExpress -i C:CreateDB.sql
This works fine, but I'm wondering if there's an easy way to put the script in the batch file, so users don't have to worry about putting the script in the C drive. I tried getting rid of the i parameter and pasting the script from the sql file into the batch file, but it didn't work.
Thanks,
Dave
View 1 Replies
View Related
May 28, 2015
In my environment, there is maintenance plan configured on one of the server and while running DBCC checkdb on a database of size around 200GB, log file usage of tempdb is increasing and causing the maintenance job to fail.
What can I do to make the maintenance job run successfully, size of the tempdb database is only 50GB and recovery model is set to simple. It cannot be increased as the mount point on which it is residing is 50GB.
View 3 Replies
View Related
Sep 1, 2006
If I start a long running query running on a background thread is there a way to abort the query so that it does not continue running on SQL server?
The query would be running on SQL Server 2005 from a Windows form application using the Background worker component. So the query would have been started from the background workers DoWork event using ado.net. If the user clicks an abort button in the UI I would want the query to die so that it does not continue to use sql server resources.
Is there a way to do this?
Thanks
View 1 Replies
View Related
Mar 14, 2008
One of my stored procs, taking one parameter, is running about 2+ minutes. But if I run the same script in the stored proc with the same parameter hardcoded, the query only runs in a couple of seconds. The execution plans are different as well. Any reason why this could happen? TIA.
View 6 Replies
View Related
Dec 26, 2006
Hi,
I want to schedule a daily job using sql server to update the info. in a sql server table. This is very new to me. Could you please forward me some helpful resources.
Thanks,
View 3 Replies
View Related
Jul 25, 2006
QuestionsI need to batch a set of update commands. Can that be done and if so what are the possible ramfications? Can one mix / match Deletes/Inserts and Updates into a SQL command via the semi-colon in a batch set? (Is this the appropriate forum?)
WHYI am unable to use the
dynamic sql building found in the dataset due to a multiple table
contstraints. I have built classes that will extract the differences
from two datasets and report on the updates/deletes and inserts
required. Since I have multiple SQL statements, it would be nice to combine them into one statement.
Platform.Net 2C#IIS6SQL Server 2000 is the eventual target database for the generated SQL
advTHANKSance
View 1 Replies
View Related
Mar 28, 2008
Hey guys, I periodically have to update maybe 300 records of the same column.. However, I've been udpating each record one by one.
Is there a way I can do something the following.ID Name1 john2 chris3 adam4 ben5 steveupdate table1 set name = name where id = ? but have it run through an entire set of these? Is there any way of automating that rather than having to update it manually? Do i need another table with just the id numbers and the column I want to change? or do i need a txt file?
View 6 Replies
View Related
Jan 22, 2002
hi,
I need some help in accomplishing this task.
I want to design a DTS task which will:
a)copy a certain given files from one directory to another
b)import the files into the tables
c)upon successful import delete the files from the original directory.
I done know much about scripting and need help in figuring out steps a) and c).
thanks
Zoey
View 2 Replies
View Related
Jul 31, 2001
Is there any way using to run already developed DTS pacalkes one after another.
Thanks
View 1 Replies
View Related
Sep 13, 2001
Do u know how to write a batch file
for example i will need to type the sql server name it has to connect to the server and run a script that I have
let me know if u have any ideas of doing it
View 2 Replies
View Related
Sep 13, 2001
Do u know how to write a batch file
for example i will need to type the server name it has to connect to the server and run a script that I have
let me know if u have any ideas of doing it
View 3 Replies
View Related
Mar 29, 2000
Can someone show me an example of the syntax required to execute multiple BCP commands within the same batch (*.bat) file?
Sorry if this is a bit of a basic question, but not being a programmer by profession, I need to plead ignorance. I've tried a few things, but I just can't seem to figure it out.
Thanks!
Rich
View 4 Replies
View Related
Oct 22, 2003
I have a problem running a batch file, now the problem is that when i run the batch file the command prompts the user for an input, but I have all the output of the bat file going into a log file. So when i run the bat file the process just sits there until i hit the 'y' key or unless i nput sumthin manually. This is a problem becuase this batch file is running on the UAT server as a job and there is no one there to input once the job is running. The commnd in the batch only requires an input once a month.
for eg if run: launch_scrt.bat and i want to put sum parameters such as 'y' or 'n' to avoid the manual input once the job is running. Any ideas?
Thanks in advance
View 11 Replies
View Related
Sep 26, 2005
Hi There,
I want to able to run a batch of sql statments (execute procedures) in SQl Server at a specific time. Just wondering if there is a method for that.
View 2 Replies
View Related
Jun 27, 2006
I like to schedule set of jobs in sql server 2005 to run in a particular sequence. How do I schedule batch jobs? Each job is a set of packages. Idea is to create a job with multiple steps and each step should be a one job but there is no option for the "sql server agent jobs" when mentioning each step.
Any idea how to create a set of jobs in sequence?
Thanks in advance,
Maria
View 2 Replies
View Related
May 6, 1999
What is the best way to run a scheduled task that fires off three scripts that need to be run sequentially? I could set up three different tasks but I don't know exactly how long each will take and they are interdependent.
View 2 Replies
View Related
Aug 10, 2004
Hi all
I have a batchjob which runs a DTS package now it calls it ok
However it is running against 2 Databases on 2 servers and I get a login error even tho I am using the sa login
does anyone know of any issues relating to this Hopefully with a soloution that does not involve a lot of work
thanks
Michael Grieve
View 7 Replies
View Related
Sep 27, 2004
In Horacle (thanks to someone else for the apt pseudonym), I am able to run a PL/SQL script saved as a file by simply typing in @ plus the path and file name. So, if I have a script called E:CreateTable.sql, I can simply enter @CreateTable.sql from the SqlPlus command line and Oracle will attempt to run all the commands in the E:CreateTable.sql file (there may be one or more commands).
Can I do the same thing in Query Analyzer (or even osql)? If so, what is the correct syntax?
Thanks,
hmscott
View 3 Replies
View Related