![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi I want to create a DTS package that does a one-off bulk import of data into a database. It needs to run this bulk import within 10 minutes of the data-files appearing in a directory; these datafiles will be generated by an "un-predictable" automated process - by that, I mean the files could appear at any time, not a predictable time. To achieve this, I thought that I could schedule the package to run every 10 minutes. If the DTS package does not find any files then it completes and waits until the scheduler restarts it 10 minutes later. However, if the DTS package does find the files, then I want it to import the data and effectively disable the scheduler. I don't want the scheduler to run the package if the files have been found. This disabling of the scheduler would have to occur before the data import has effectively started...if the data import takes more than 10 minutes then I don't want the DTS package running in two (or more) instances. I'm not sure how to go about this. I can't find a way of getting the DTS package to disable it's own schedule. The other way I though of doing this was to have a global variable within the DTS package called "RUN" that was a boolean value. If the value was TRUE then the package would run and if it was FALSE then the package wouldn't run. As soon as the DTS package had verified that the data files were there then it would have to set the value of the global value to FALSE. However, this would have to be durable data, so the DTS package would immediately have to save it self to make this "FALSE" value permanent so that subsequent runs of the DTS package realised that the files had been found in a previous run. I certainly wouldn't want the package to be run again, particularly if an existing import was still taking place. However, I don't know how to make a DTS package save itself during execution. Is what I'm trying to achieve possible? If so, what's the best way to go about it? I realise that I could simply rename or move the data import files, so that the files effectively aren't there, but this isn't "perfect". Many thanks in advance Griff |
#3
| |||
| |||
|
|
If a job is already running, won't it automatically refuse to run again? "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message news:emPohbgRDHA.1304 (AT) TK2MSFTNGP11 (DOT) phx.gbl... OK What you can do is Build a package to import the files. First step in the package is to check the file count in the directory. If there are < the total amount then exit gracefully using workflow. The very last step of the job, when the job has run is to execute Execute msdb.dbo.sp_Update_Job. You need to pass in the job name and the enabled property setting it to false Schedule the job to execute every 10 mins If you then want to do the same the following day you have a seperate job that simply re-enables the job first thing -- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "GriffithsJ" <jonathan.griffiths (AT) ipuk (DOT) com> wrote in message news:uW4gbHgRDHA.2148 (AT) TK2MSFTNGP11 (DOT) phx.gbl... Hi I want to create a DTS package that does a one-off bulk import of data into a database. It needs to run this bulk import within 10 minutes of the data-files appearing in a directory; these datafiles will be generated by an "un-predictable" automated process - by that, I mean the files could appear at any time, not a predictable time. To achieve this, I thought that I could schedule the package to run every 10 minutes. If the DTS package does not find any files then it completes and waits until the scheduler restarts it 10 minutes later. However, if the DTS package does find the files, then I want it to import the data and effectively disable the scheduler. I don't want the scheduler to run the package if the files have been found. This disabling of the scheduler would have to occur before the data import has effectively started...if the data import takes more than 10 minutes then I don't want the DTS package running in two (or more) instances. I'm not sure how to go about this. I can't find a way of getting the DTS package to disable it's own schedule. The other way I though of doing this was to have a global variable within the DTS package called "RUN" that was a boolean value. If the value was TRUE then the package would run and if it was FALSE then the package wouldn't run. As soon as the DTS package had verified that the data files were there then it would have to set the value of the global value to FALSE. However, this would have to be durable data, so the DTS package would immediately have to save it self to make this "FALSE" value permanent so that subsequent runs of the DTS package realised that the files had been found in a previous run. I certainly wouldn't want the package to be run again, particularly if an existing import was still taking place. However, I don't know how to make a DTS package save itself during execution. Is what I'm trying to achieve possible? If so, what's the best way to go about it? I realise that I could simply rename or move the data import files, so that the files effectively aren't there, but this isn't "perfect". Many thanks in advance Griff |
#4
| |||
| |||
|
|
If a job is already running, won't it automatically refuse to run again? "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message news:emPohbgRDHA.1304 (AT) TK2MSFTNGP11 (DOT) phx.gbl... OK What you can do is Build a package to import the files. First step in the package is to check the file count in the directory. If there are < the total amount then exit gracefully using workflow. The very last step of the job, when the job has run is to execute Execute msdb.dbo.sp_Update_Job. You need to pass in the job name and the enabled property setting it to false Schedule the job to execute every 10 mins If you then want to do the same the following day you have a seperate job that simply re-enables the job first thing -- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "GriffithsJ" <jonathan.griffiths (AT) ipuk (DOT) com> wrote in message news:uW4gbHgRDHA.2148 (AT) TK2MSFTNGP11 (DOT) phx.gbl... Hi I want to create a DTS package that does a one-off bulk import of data into a database. It needs to run this bulk import within 10 minutes of the data-files appearing in a directory; these datafiles will be generated by an "un-predictable" automated process - by that, I mean the files could appear at any time, not a predictable time. To achieve this, I thought that I could schedule the package to run every 10 minutes. If the DTS package does not find any files then it completes and waits until the scheduler restarts it 10 minutes later. However, if the DTS package does find the files, then I want it to import the data and effectively disable the scheduler. I don't want the scheduler to run the package if the files have been found. This disabling of the scheduler would have to occur before the data import has effectively started...if the data import takes more than 10 minutes then I don't want the DTS package running in two (or more) instances. I'm not sure how to go about this. I can't find a way of getting the DTS package to disable it's own schedule. The other way I though of doing this was to have a global variable within the DTS package called "RUN" that was a boolean value. If the value was TRUE then the package would run and if it was FALSE then the package wouldn't run. As soon as the DTS package had verified that the data files were there then it would have to set the value of the global value to FALSE. However, this would have to be durable data, so the DTS package would immediately have to save it self to make this "FALSE" value permanent so that subsequent runs of the DTS package realised that the files had been found in a previous run. I certainly wouldn't want the package to be run again, particularly if an existing import was still taking place. However, I don't know how to make a DTS package save itself during execution. Is what I'm trying to achieve possible? If so, what's the best way to go about it? I realise that I could simply rename or move the data import files, so that the files effectively aren't there, but this isn't "perfect". Many thanks in advance Griff |
![]() |
| Thread Tools | |
| Display Modes | |
| |