Running SQL In A Batch Program
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
ADVERTISEMENT
Sep 7, 2006
Can someone point me to some examples of batch scripts that will allow me to write a simple tool which can reliably detect if any instances of SQL servers are running on a machine and if running, then their names.
Hopefully the tool should be robust enough to run on diff flavors of MS Windows.
Thanks
View 1 Replies
View Related
Apr 29, 2008
hello,
I have to write a batch file program that will just copy the names of the files from a particular folder.
Which means some command that could go into that folder through a path provided and get/copy just the name of the file.
Regards
Thank You
View 2 Replies
View Related
Sep 10, 2007
Hello All,
I want to write Batch Program which will insert Data into Table every day based on some conditions.
can anyone please let me know how to write Batch Process in SQL server 2005??
Thanks.
View 5 Replies
View Related
Mar 13, 2007
I am able to run it from the file system but when I try running it from SQL Server I get an error message that it cannot load package. I am using the following code.
Package package = app.LoadFromSqlServer("trans_hist", Properties.Resources.dbServerName, Properties.Resources.userId, Properties.Resources.password, null);
View 6 Replies
View Related
Mar 7, 2001
My program is copying several hundred thousand records from an Access DB to a sql server 7 db. It has to do some conversions and lookups along the way. At seemingly random times, a DBCC job gets started up by the system that locks up my program.
Any thoughts as to why it happens? What I can do to detect/prevent it so that my program doesn't lock up?
View 6 Replies
View Related
Jun 9, 2015
we run std 2008 r2. I'll be putting together a pkg whose last step needs to execute a program that resides on a remote (not same as where pkg runs) computer and that program must run on the remote computer. Return code(s) would be important to the pkg. I see talk about running over http which may or may not be possible with that remote ws 2003 sp2 server.
The pkg will be running on a ws 2008 r2 std sp1 machine.Does the community have any recommendations for running a remote program from ssis?
As I think about it, i'm not a big fan of making a pkg wait for another process synchronously. So I may just want to trigger the remote program and let something I would set up on the remote server tell me daily if the program succeeded. Interestingly this is a rewrite of a pentaho job that does wait for the remote program execution. I suppose installing ssis on that remote server is an option but I think i'd get a lot of resistance going that route. I'll probably be triggering a sql agent to ssis job after that remote program finishes.Â
View 10 Replies
View Related
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
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
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
May 23, 2007
why we use sql exceptions ...
what the program will do if we caught that exception .. i need some suggestions ... i got this exception(String or binary data would be truncated.
The statement has been terminated.).. will it affect the functionality of the program...
hiow can i avoid this exception..
View 1 Replies
View Related
May 21, 2007
Can I return a value in a variable from a SSIS program back to C# after the SSIS program is run from C#?
View 1 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
Aug 29, 2001
i have a program which should give the out like this
XAPIALTMKT20010829105525.TXT
but its giving the output = 'X'
which is just the first initial...how
can i get this...
if i don't write the @filename=....
only then its giving the output..but i want to store it in the
varable..how can i do that
================================
declare
@v datetime ,
@filename varchar
select @v=getdate()
select @filename='XAPIALTMKT'
+CONVERT(varchar, @v, 112)
+SUBSTRING(CONVERT(varchar, @v, 108), 1, 2)
+SUBSTRING(CONVERT(varchar, @v, 108), 4, 2)
+SUBSTRING(CONVERT(varchar, @v, 108), 7, 2)
+'.TXT'
print @filename
================================================
thanks,
Harish
View 2 Replies
View Related
Jul 23, 2005
It is very interesting to me that most people in this group can't do simpleSQL. Are you viewing MySQL as a simple file system?As long as you do that,you willnot understand SQL in any dialect. So from now on:When you have a question about SQL. post the table structures. Uh, "WithCreate".Post some sample data in the form of INSERTS.Regards,Rich--The journey is the reward.
View 2 Replies
View Related
May 22, 2006
Hello, i installed :
SQL Server 2005 Express Edition with Advanced Services
Install Microsoft SQL Server 2005 Express Edition with Advanced Services
but I do not see any program in my program menu to open it. Is this a stand alone program I can open? Thanks
View 2 Replies
View Related
Oct 10, 2007
Hi All,
I am trying to send an email from a cmd prompt from SQL Server 2005 server using mailsend program. I am getting the message "Could not send mail". I am really stumped, don't know how to fix it. Any suggesstions?
Thanks.
View 3 Replies
View Related
Oct 9, 2007
Hi All,
I have installed SQL Server 2005 and created a job. I made the job failed to test the mailsend program. The notification step that uses the mailsend succeeded but I did not get an email. I am using mailsend program on SQL Server 2000 and it works fine. I am really stomped and don't know what to do to fix it?
Thanks.
View 9 Replies
View Related
May 14, 2008
I've have following table,
tblHIT - this table will reveive record every minutes
Date | Time | Main_ID | Hit
------------------------------------
3/1/2006 | 100 | 200 | 8700
...
...
...
4/14/2008 | 100 | 200 | 4500
4/14/2008 | 100 | 201 | 8700
4/14/2008 | 200 | 200 | 3500
4/14/2008 | 300 | 201 | 7700
...
...
I've also 1 job in SQL Server Agent will execute STORED PROCEDURE and will filter 7 days record before from current date and insert it into tblHIT_7days. tblHIT_7days shown as follow
tblHIT_7days
Date | Time | Main_ID | Hit
------------------------------------
3/7/2008 | 100 | 200 | 8700
...
...
...
4/13/2008 | 100 | 200 | 4500
4/13/2008 | 100 | 201 | 8700
4/13/2008 | 200 | 200 | 3500
4/13/2008 | 300 | 201 | 7700
I've plan to create TRIGGER. This TRIGGER will insert the appropriate record from tblHIT into tblHIT_7days and also delete a appropriate record in tblHIT_7days. This INSERT and DELETE transaction depend on current date.
Is it possible, TRIGGER can do this?
View 6 Replies
View Related