job for collecting data

  • I need a script to copy data from one table(source) to anotehr table (destination),

    i want to sheduling this task for every 5 minute , rows which data were copied before don't copy again.

  • eh.shams (9/17/2012)


    I need a script to copy data from one table(source) to anotehr table (destination),

    i want to sheduling this task for every 5 minute , rows which data were copied before don't copy again.

    What columns/data do you ahve to detect what are new rows? What's the table look like? what tools do you have available? SQLAgent, SSIS, what is available?


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • source table is like this one :

    Customer Code|cslAccumulationInvoiceItmId| cslAccumulationInvoiceRef |cslDeliveryNoteRef| cslProductRef |Amount |Rate CurrencyRate| price before PriceInBaseCurrency| Deliver No| Date-Reci

    400560 46663 46644 28532 21 21.54 504807 1 10873542.78 10873542.78 17169 1/10/2012 00:00

    400560 46659 46644 28488 21 22.86 504807 1 11539888.02 11539888.02 17146 1/10/2012 00:00

    400560 36414 36413 19204 47 17.66 519230 1 9169601.8 9169601.8 10956 11/30/2011 00:00

    400560 35305 35304 18176 47 24.12 519230 1 12523827.6 12523827.6 10361 11/27/2011 00:00

    400560 96490 96488 84639 47 22.26 568000 1 12643680 12643680 27082 8/8/2012 00:00

    400560 35312 35304 18465 47 22.7 519230 1 11786521 11786521 10549 11/28/2011 00:00

    ______________________________________________

    on the destination i have same table , with only add status (bit) column.

    i want to reade from destination and if the status is false , send a message to customer, every 5 minute for example.

    on server i have MSSQL SERVER 2008 SP1,

    sql agent is ready to .

  • eh.shams (9/17/2012)


    source table is like this one :

    Customer Code|cslAccumulationInvoiceItmId| cslAccumulationInvoiceRef |cslDeliveryNoteRef| cslProductRef |Amount |Rate CurrencyRate| price before PriceInBaseCurrency| Deliver No| Date-Reci

    400560 46663 46644 28532 21 21.54 504807 1 10873542.78 10873542.78 17169 1/10/2012 00:00

    400560 46659 46644 28488 21 22.86 504807 1 11539888.02 11539888.02 17146 1/10/2012 00:00

    400560 36414 36413 19204 47 17.66 519230 1 9169601.8 9169601.8 10956 11/30/2011 00:00

    400560 35305 35304 18176 47 24.12 519230 1 12523827.6 12523827.6 10361 11/27/2011 00:00

    400560 96490 96488 84639 47 22.26 568000 1 12643680 12643680 27082 8/8/2012 00:00

    400560 35312 35304 18465 47 22.7 519230 1 11786521 11786521 10549 11/28/2011 00:00

    ______________________________________________

    on the destination i have same table , with only add status (bit) column.

    i want to reade from destination and if the status is false , send a message to customer, every 5 minute for example.

    on server i have MSSQL SERVER 2008 SP1,

    sql agent is ready to .

    As mentioned by Kraig

    What columns/data do you ahve to detect what are new rows?

    Based on that you can have UPINSERT script and schedule it as per your need.

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • would you please be more specific , or let me know with example ?

    Thanks

  • eh.shams (9/17/2012)


    would you please be more specific , or let me know with example ?

    Thanks

    e.g. in Source and Destination table CustID is unique number then we can have below query to insert only new records

    INSERT INTO dest_tbl (Col1,Col2, .....)

    SELECT Col1,Col2, FROM sorce_tbl

    WHERE NOT EXISTS (SELECT CustId FROM dest_tbl )

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • thanks , how i can create job to do it ,periodicaly ?

  • eh.shams (9/17/2012)


    thanks , how i can create job to do it ,periodicaly ?

    That could be a very involved question. I suggest you look through the Stairway to SQL Server Agent series: http://qa.sqlservercentral.com/stairway/72403/

    You'll probably only need to read the first 3-4 articles to do what you need to do.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Thank's

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply