Home Forums SQL Server 2008 T-SQL (SS2K8) Finding the last records inserted into all tables in a database RE: Finding the last records inserted into all tables in a database

  • bryan.holmstrom (7/27/2015)


    Thank you for the quick reply but I need the actual tables not the system tables.

    Database = 'xxxCRM'

    Example table = accountbase (field = 'modifiedon' or even 'createdon' for each record in the table.

    Account Name CreatedOn ModifiedOn

    Barney Ruble '07/27/2015' '07/25/2017'

    yes exactly. run my query.

    it finds the "actual" table names, and generates the queries you would need.

    so if the table [accountbase] has a column named [ModifiedOn], it would be among the generated commands.

    my query helps if you have lots and lots of tables with that column; if it was only two or three tables, you could do it manually, but you want to leverage any datasources(like the list of columns) when you can.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!