How To Make SqlServer Agent Execute Windows Service
Mar 24, 2004
To run a remainder service that shoots a mail once everyday to all users of a subscribed service satisfying a pre-determined criteria, I'm planning to use a Sql Server Agent Job. In the first step of the Job, I'll have a stored procedure that gets all the records matching that criteria & store it in a table.
In the next step, I want a Windows Service (as there need not be any interface & my project requires easy deployment & minimal manual intervention) to fetch the records from the above table & shoot mails to users of the subscribed service. Several thousand mails may have to be sent this way. In order not to strain Sql server & also avoid extended stored procedures due to safety reasons, I'm considering using this windows service.
I want to know
1) how to make the Sql Server Agent execute the Windows service?
2) abt code or resources on how to write a vb.net Windows service that will work through a recordset & send mails.
3) from a perfomance point of view, if this method is feasible? If not, what are the other efficient alternatives.
hi, can anyone explain, how to execute package with sql server agent:
the problem is::
i made a integration service package (in visual studio 2005). When I 'm in visual studio and do "execute" the package it works well. Then I build a dtsx file. When i double click on it, it opens and if i do execute, it works well.
I want to execute the package every week automatically. I write a job in SQL server agent, in Steps I choosed Type=SQL server Integration service packege, then General->packacge source -> file system, and then wrote where the dtsx file is (which was built). "Run as" I choose my user name.
then i'm trying to start a job, but it fails, and writes "The package execution failed."
Need some help... When we tried to run mulitple packages one after the other from a windows service, first one succeeds but later ones are throwing below error : "The script threw an exception: The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there. A deadlock was detected while trying to lock variable "System:ackageName, User::BusinessDate, User::Environment, User:ortfolioName" for read access. A lock could not be acquired after 16 attempts and timed out."
Later, we tried to create separate AppDomains for each package and execute via console application, but ended up with below error (The below expressions were defined in OnError Event) : "The result of the expression "@[User::ReportErrorFrom]" on property "FromLine" cannot be written to the property. The expression was evaluated, but cannot be set on the property. The result of the expression ""Error At :" + @[System:ourceName] + "" + "Error Description : "+ @[System::ErrorDescription] + "" " on property "MessageSource" cannot be written to the property. The expression was evaluated, but cannot be set on the property."
At last, we tried to span a separate process (System.Diagnostics.Process) for each package. this seems working but taking very long time: A package that normally takes 2 min, is taking 60 min.
We also tried creating an SSIS Package that executes mulitple packages. But only first package is getting executed, and second one is throwing below error (Here the variable it is trying to lock is of first package): "Failed to lock variable "UniqueInstrumentsQuery1" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".
Please help us with some work around for this. Thanking you in advance,
When running an integration services package from a windows service I get the "Object ... has been disconnected or does not exist at the server." exception after aproximately six minutes of execution.
This is *not* my windows service failing. I can loop indefinately while tracing to a log file within the service and it will run forever. While calling the mypackage.execute(...) method however, after six minutes (give or take) the exception is thrown...
my code looks something like this: <code> dim foo as Microsoft.SqlServer.Dts.Runtime.Application mypackage = foo..LoadPackage(strimportPkgFilename, pkgevents) results = myPackage.Execute(Nothing, Nothing, pkgevents, Nothing, Nothing) </code>
<error> A first chance exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll Exception in: frmMyForm.DoImports Message: Object '/b76f98a0_5bd9_49d8_a524_eeb49d55b303/bqbhkjnaofq_ifr_cwz+srid_1.rem' has been disconnected or does not exist at the server. </error>
oddly, this same code works perfectly if I run it within a windows form application no matter how long it takes.
It also runs fine if the package can complete in under six minutes.
when I run a package from a command window using dtexec, the job immediately says success. DTExec: The package execution returned DTSER_SUCCESS (0). Started: 3:37:41 PM Finished: 3:37:43 PM Elapsed: 2.719 seconds
However the Job is still in th agent and the status is executing. The implications of this are not good. Is this how the sql server agent job task is supposed to work by design.
I am attempting to write a Windows service that watches a database for uploaded files to import. When a new file is found, the corresponding SSIS package is run from the file system with variables passed through. I started development as a Windows app and copied the functionality to a service.
The app runs fine. The service does not. I get a "Failure" each time a package is executed. Everything is identical behind the scenes with the obvious exceptions that OnStart and OnStop handlers are buttons in the app. I added a script task at the beginning of one of the SSIS packages to notify me that it is even running at all. It doesn't even hit that initial task.
Again, the app will run all packages just fine. The data is imported and the results return as "Success."
The following is the code executing the package. Any help is appreciated. I've been banging my head on this one for a few days now. (Is there a tag to format a code sample?)
Dim pkgLocation As String Dim pkg As New Package Dim app As New Application Dim pkgResults As DTSExecResult
Hi all, I do understand that it is highly recomended to have aserprate user (perfered a domain user account) for each of the SQL Server service and SQL Agent service. What is the reason behind that? (Someone told me to not run the service with an account that has a powerul privilegs! - I don't undrstanmd this point can you explain it please?) What is the diffrent between: 1- Local System account 2 -Network Service account
I am looking at implementing some sort of throttling whereby "expensive" reports are setup as Subscriptions (and hence are run by the Windows Service), while all other requests go the Web Service.
My question is:
Do the two systems share any underlying systems? I understand (of course) that they use the same DB, etc. etc. However, I can't quite tell whether there is an underlying engine that is a common base or if they really just spin up different instances of the same objects and essentially each host the application separately?
Hi! guys,I have a SQL agent job fails because it gets 10 warnings when it runsa stored procedure. These warnings are trivial and can be ignored. CanI make it ignore these warnings and proceed? I think there is somesetting I can do to change the default behavour of an agent jobregarding warnings but I just don't know how to do it.Any idea?Thanks,Gary
Hi, here is my Sql server Configuration: 1. Created an account for sql server named "accountName" I am running sql server with no problem. Now I want to incorporate sql mail. so I created an eamil account. Can I use the sql server log name in SQLServerAgent, so both sql server and sql server agent use same account name, or I have to create a new account name for sqlserver agen?
Hi All, Running Sql Server 2000 for Windows 98. How do I start the SQL Server Agent Automatically (that is at OS startup). Is there a way to do it at all ?
Currently I am running a SSIS package scheduled daily at 7 A.M. It expects two feed files from two different folders. The first step in my package will rename the input files in those folders to names which the package can understand. I have created two variables in my package to read the files with those file names. I used these variables in connection managers.
If any of these folders doesn't have input files when the package runs, the package will fail.how to make the package the run successfully even there is no input feed?
I am trying to execute a SSIS package programmatically. When a user drops a file in a shared folder, we execute the package based on that file. I am using SqlServer.DTs.Runtime.Application.LoadPackage() and SqlServer.DTs.Runtime.Package.Execute() functions each time to do this.
The problem is, when, say two people drop a file, the second one will not execute untill the first one is completed. I also tried only calling LoadPackage() a single time, and then storing the instance and calling Execute() in a different thread on each file drop; although the blocking still occurs. I assume the Package object is the one doing the blocking then behind the scenes.
Is there any built in functionality to make these functions (Application.LoadPackage() and Package.Execute()) run async? If not, has anyone had much success sticking these calls into a thread? I tried sticking these calls into a thread using System.Threading.ThreadPool.QueueUserWorkItem(), and this appears to work, however it randomly crashes the program when I drop multiple files one after the other. The exception also isn't too helpfull (pasted below):
"The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails."
So, is what I am trying to do possible? I know it must be, because when I was using .NET 1.X, I was just calling dtexec via the command line, and dtexec was able to execute many packages simultaneously....
My report works with XMLDP data provider and obtains source data as a result of a web method call. This memthod returns all data necessary for the report. Thus, all of about 20 report datasets query the same web method with the same parameters and then select appropriate data with different ElementPath expressions. It's so inefficient and time-consuming! I cant have respective web method for every dataset. How can I configure SSRS to call web method only once while the report is executing? Or how can I leverage the performance at all?
I am doing some research to see if the Service Broker technology would help my company with our Enterprise application. Here is our scenario: We have a 3 tier system. The first tier needs to contact the second tier asynchronously. Hence, using queues is a good option. However, the process that needs to happen on the second tier is mostly process intensive with little database updates. Is it still worth our time to use Service Broker?
I like the concept of Activation that Service Broker provides. But, from what I am reading most of the documentation describes activation as a way to call another stored proc. I definitely dont' want to do any process intensive work on the SQL server. So here comes my question...
How would I use a windows service to listen to the activation event from the Service Broker. I could have multiple windows services watching the same queue (scalable). Would I have to handle collisions myself? If so, I think I would rather keep it simple, and just use a simple table as my queue.
I have built packages on SQL Server 2005 using the Import/Export wizard. The basic aim is to import a table from an Oracle database into my SQL database. It was running fine until recently when they Oracle database was upgraded to 10g (i think), and now something is wrong. If I run the saved package as administrator, it runs fine, but when I run it as part of a Agent schedule job, it seems to loose the password. The error message is not very descriptive ("The job has failed."), so i might be mistaken.
Hi everybody, I have a problem with windows NT & sqlserver.. Before stating the problem i will decribe the configuration of our system. We have windows NT4.0 sp6 with 4gb of ram and 800gb of hard drive space with 4 processor. we have installed sqlserver 2000 on it. Our production database occpuies 32gb of data.Production db has lot of filegroups and file .
we are having a table which has 12million of rows , 40 columns and 6 indexes.
The problem we facing is when we try to alter the table(i.e) trying to change from char to int ...windows NT and sqlserver hangs...we have to reboot the system everytime. When we try to delete the indexes we found out that,it even hangs for deleting the indexes. So we thought it would be better to run a Dbcc checkdb on that database...shockingly it even hangs for the dbcc commands.. Anyone knows wht would cause this problem
Is there a way that I can allow several users to read, edit (add/delete steps), and execute the same job? I've read that you cannot assign a windows group as the owner of a sql server agent job but hopefully there is a workaround.
My package takes 1 global variable and I have set up jobs to run this SSIS with different variable values.
I select the package using the UI provided via the job set up screen. The job step type is Operating system (CmdExec).
When package are run by job, it seems that the job can not find the package. But, how can it not find the package when the package was selected from a list that the UI displayed? The error is below.
"Executed as user: <<LOGGEDIN USER(with admin right)>>. The process could not be created for step 1 of job 0xFECED6C09CC650489084E91C2FCF52FB (reason: The system cannot find the file specified). The step failed."
I am trying to run an executable via a scheduled sqlserver job. I have set the jobstep type to CMDEXEC; and the commands for the jobstep that I have tried are:
start c:estinsertindb.exe c:estinsertindb.exe c:estinsert.bat insert.bat above contains c:estinsertdb.exe or start c:estinsertdb.exe Is there an exception that will not allow a job to run an exe file?
I am running into a similar problem using the NT scheduler via the "at" command. With NT, I run a bat file with the following command to create a scheduled task or job (at 10:10 /every:M,W,F c:estinsertdb.exe). At 10:10, when the job is scheduled to run, nothing happens; but if I edit the job and manually start the job, it runs.
Currently I cannot connect to a database, I got the system.exception €śPlatformNotSupportedExcoption€?. This database is Polish (COLLATE Polish_CI_AS), when I collate this database to latin general it works fine. I connect by using the system.data.sqlclient.sqlconnection, as far as I can see I cannot set the locale identifier here€¦ What can I do??? Thanks for your help! regards, Jan
I am having trouble running a package in SQL Agent. The step involves zipping up a number of files using SQL Agent. I know in the error message it states "Access is denied" but I can run the package manually in BIS. Also I have applied a SQL proxy to the step using my own credentials which have rights to the file location, but still no luck.
I get the following error:
Error: 2008-03-10 09:04:02.04 Code: 0xC002F304 Source: Call ZipFiles Batch Execute Process Task Description: An error occurred with the following error message: "Access is denied". End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 09:04:00 Finished: 09:04:02 Elapsed: 1.219 seconds. The package execution failed. The step failed.,00:00:02,0,0,,,,0
Whenever i change the SA password to anything else, my SQL Agent services like jobs, alerts starts falling, and if i attempt to stop and then restart sql agent service, it will not start again.
My server uses sql authentication for everything...
Hello, I am having a problem with my sql server agent service not working. I have done some research from earlier postings and still having no luck with getting it up and running.
Problem: "Could not start the SQLSEVERAGENT service on local computer. could be an internal Windows errow or service error.
2006-05-09 14:23:55 - ! [298] SQLServer Error: 6, Specified SQL server not found. [SQLSTATE 08001] 2006-05-09 14:23:55 - ! [298] SQLServer Error: 11001, ConnectionOpen (Connect()). [SQLSTATE 01000] 2006-05-09 14:23:55 - ! [000] Unable to connect to server '\PROBLEMTRACK'; SQLServerAgent cannot start 2006-05-09 14:23:55 - ? [098] SQLServerAgent terminated (normally)
I have reset the password for the 'sa' account and running it and got error: Error 18456: login failed for user Specify a different account to be used. But when I try it only provides me with the 'sa' account.
My primary goal is to run some DMP ion the databases that I have on the server.
We came across a biggg issue with SQL Agent service on one of our SQL Server 2012 production servers. Suddenly, it stopped working. So we just thought of disabling and enabling the service, but once we disabled and try to set automatic (before starting it), gives us error message "The Remote Procedure Call Failed [0x800706be]".
Sql server service has been started with a normal user who do not have any permission but he is a domain user. The sql server service can be started successfuly in cluster
But if the Same user is used to start the SQL Server Agent service there is an error.What is the mininumum priviledge to start a sql server agent in cluster. Why it cannot the domain user cannot be used to start the sql agent service.
Hi !when installing sqlserver 2000 on a Windows 2003 server it explicitlytells "server not compatible with Windows 2003" during install, but itcan carry on.After we applied serfice pack 3a then the db server seems to runnormally, but does it risk to behave randomly afterwards ???Is sqlserver 2000 standard edition compatible with Windows 2003 server?Or does it exist a specific sqlserver edition for Win2003 ?thanks !Patrice