Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Job WaitTime

Posted on 2011-03-03
8
Medium Priority
?
363 Views
Last Modified: 2012-05-11
Hi all
I have an Sql Job that executes every 5 mins.
The data source A, that feeds  table B, that SQL job works on has sporadic nature,
Some time the transaction arrive in sequence sometimes not.

how can I control the SQL Job to wait for 1 mins during the execution,
and what is the side effect,

Thanks
Regards
0
Comment
Question by:ZURINET
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 7

Assisted Solution

by:lozzamoore
lozzamoore earned 1500 total points
ID: 35025433
If you want the SQL job to explicity wait for 1min, you can add this to the script/stored proc:

WAITFOR DELAY '00:01:00.000'

However, I'm not convinced this is the best approach.

Could you post a little more background detail on the specific sequence problem you have please?

Thanks,

L
0
 
LVL 25

Expert Comment

by:slam69
ID: 35025520
hmm have posted same comment 3 times now not sure what is happening......

if its a two step process you are exectuting in one script, consider separating out the scripts into 2 steps within an sql qgent job.

if its more complicated than that then consider using an SSIS package which gives you greater control of teh data flow
0
 

Author Comment

by:ZURINET
ID: 35025592
New Record
TransactionID      Done      Type      TransactionID      ProductID      ValidFrom                  ValidUntil

210857            0      PREIS      220000000065ws0p      8208      2011-01-31 00:00:00.000            2011-06-30 00:00:00.000
210846            0      PREIS      220000000065ws25      8208      2011-07-01 00:00:00.000            2099-12-31 00:00:00.000


Existing Record needed update
TransactionID      Done      Type      TransactionID      ProductID                      ValidFrom                                   ValidUntil
210837            0      PREIS      220000000065ws0p      8208      2011-01-31 00:00:00.000            2011-12-31 00:00:00.000


I need to update recordd 210857 and Insert record 210846 with a rule that the validity date (from and until) should not cross over between two records
in the destination DB

The problem is if record 210857 is delayed as the New Record info id shows,
The It cannot be processed because the date will cross each other.
Hence I need a way to tell the transaction to wait with the insert of 210846 until 201857 Arrives.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:ZURINET
ID: 35025602
typo error TransactionID = fk_TransactionID (210857),
0
 

Author Comment

by:ZURINET
ID: 35025726
Hi slam69

I am using 2 Jobs/Scripts at the moment..
The issue is can I schedule the second job to run after 2 mins of the first one .. I mean in sync..

Regards
0
 
LVL 7

Accepted Solution

by:
lozzamoore earned 1500 total points
ID: 35025752
Well it looks like you need to introduce a sequence field (or previoustranid field), otherwise how will the later transaction know that there is one preceding it?

Otherwise, there are features built into SQL Replication or SQL Broker services that will guarantee transactional order into the data transfer.

L
0
 
LVL 7

Expert Comment

by:lozzamoore
ID: 35025792
If you add a PrevTranId record, then you can do an EXISTS check for this record, and a loop that WAITFOR a period of time before a retry.

This runs the risk of an endless loop, so perhaps a max cycle of 5 re-tries, before it stops and fails the insert...

L
0
 

Author Closing Comment

by:ZURINET
ID: 35056194
I used Triger to solve the problem
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question