dynamically selcting first 10 records from many tbls

  • is it possible to autometically system to create a table where its populate first 10 recrords whenever i new table being created.

    also another table for last ten records

    thanks

    neil

  • NEAL-464478 (8/30/2010)


    is it possible to autometically system to create a table where its populate first 10 recrords whenever i new table being created.

    also another table for last ten records

    For starters, everything and anything is possible.

    Having said that spec is too vague to understand the business rule behind it.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • well, i dont make rule, i am the slave of my master. So master wants me to make something like a table pick first 10 records from unknown number of tables, have it in one table or even a view work.

    for sure i know that tables the data coming from get updated once and then stays as it is without change, daily user making at least 10 tables in the database. and each tables holdes 500 to thousands record even. which they bul upload from another software for production reason.

    so if you have any idea please help me out. thats all info i can get from my master.

    thanks

  • NEAL-464478 (8/30/2010)


    well, i dont make rule, i am the slave of my master. So master wants me to make something like a table pick first 10 records from unknown number of tables, have it in one table or even a view work.

    for sure i know that tables the data coming from get updated once and then stays as it is without change, daily user making at least 10 tables in the database. and each tables holdes 500 to thousands record even. which they bul upload from another software for production reason.

    so if you have any idea please help me out. thats all info i can get from my master.

    I assume the name of these "unknown number of tables" is either stored in some place or will be provided by user at running time, isn't it?

    If that's the case, load table-names into a cursor then loop the cursor dynamically generating on-the-fly then executing whatever select top ten statement "your master" is asking for.

    To accomplish this you have to understand how "cursors" work and how "dynamic sql" works.

    Hope this helps.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Viewing 4 posts - 1 through 3 (of 3 total)

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