how to filter monthly data from a yearly data file ?

  • Rankerg (1/10/2016)


    That is the requirement, any changes to any column means that is a CHANGED / MODIFIED record and these CHANGED/ MODIFIED files I want ? duplicates to be ignored

    [Deep breath]

    As I've said before, we are not in the game of guessing, neither the questions nor the answers!

    😎

    If you need to create a merge or a delta of existing and incoming datasets then thats easy, if you want to time travel then that's slightly harder but doable, if you want an answer to a question that hasn't been asked then that's impossible.

  • Yes I think this is pretty close, I want the amended and new records in a NEW File

  • Rankerg (1/10/2016)


    Yes I think this is pretty close, I want the amended and new records in a NEW File

    am a bit confused...what are you going to do with your NEW FILE ?

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Rankerg (1/10/2016)


    Yes I think this is pretty close, I want the amended and new records in a NEW File

    Now it's time for you to post the full requirements and all the information needed to answer your question

    😎

  • so the application which I am going to feed this NEW Files expects DELTA (amended and new) records only, if it is existing / duplicate records then it will move the current file from PRODUCT Table to PRODHISTORY table and since we get around 300k records every month there will be redundant data in the HISTORY table.

  • I get a flat / EDI file from client and ETL to the DB and since the client is sending entire yearly data instead of DELTA I need to filter the DELTA records. I am not sure WHAT ELSE I can provide, I already mentioned the file has 140 columns / fields

  • Rankerg (1/10/2016)


    I am not sure WHAT ELSE I can provide, I already mentioned the file has 140 columns / fields

    Hugo already explained.

    So if any tables are involved (I assume there are, otherwise you wouldn't post on this site), then post their schema, in the form of a CREATE TABLE statement that includes all the constraints.

    For any tables that contain data (imported data or existing data), provide us with sample data in the form of INSERT statements. Please test the CREATE TABLE and INSERT statements. The easier it is for us to recreate your problem, the more chance we are willing to help you - and copy, paste, execute is the easiest it gets.

    If external data sources are involved, tell us exactly what they look like. If for instance you import Excel sheets, then either attach a sample sheet, or post a screenshot of a sheet. Of course if you already imported the Excel data into a staging table, then simply give us that table (CREATE TABLE and INSERT statements) instead.

    For all the sample data posted, keep in mind that it has to be representative (i.e. all normal and special cases should be included), and as short as possible (so don't post your two-million row production database, but create a sample that illustrates the issue in ideally less than a dozen rows).

    Finally, post the expected results. For this a tabular format is often ideal (as a screenshot or use a fixed-width datatype, and check in preview mode that spaces are retained - use the code tag if needed). Also, remember that what's be obvious to you may not be obvious to others, so do add some explanation to help us understand how the sample input data results in the posted end result.

    So that's 4 things:

    CREATE TABLE statements for all tables involved

    Sample data for those tables

    A sample of the file you're importing

    What you want as results at the end

    Sure, the file has 140 columns, but we have no idea what they are, what data types they are, what the imported data looks like (the previous month's data that needs to be compared with), and, more importantly, we can't test any code we write.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Rankerg (1/10/2016)


    Yes I think this is pretty close, I want the amended and new records in a NEW File

    give us a clue......how close? whats incorrect?

    sample scripts as already asked for will help us help you

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Rankerg (1/10/2016)


    I get a flat / EDI file from client and ETL to the DB and since the client is sending entire yearly data instead of DELTA I need to filter the DELTA records. I am not sure WHAT ELSE I can provide, I already mentioned the file has 140 columns / fields

    If most of those 140 columns are supposed to be treated the same, then by all means trim it down to a dozen or so before posting. I am sure you can copy/paste/change the pattern once there is a good solution.

    But we really, really, really need to have actual tables, and actual data, in our hands in order to help you. Otherwise it'll just continue to be a guessing time, wasting both your and our time.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • So creating a store procedure and like to pass table name as parameter?

  • Rankerg (1/11/2016)


    So creating a store procedure and like to pass table name as parameter?

    No.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

Viewing 11 posts - 16 through 25 (of 25 total)

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