Data base testing sql query

  • could you post the structure of the table and some sample data? Should be fairly easy. You might have to do a summary query to do the counts and then join back to the same table to get the keys.

  • Hi ,

    Thanks for the response. Have attached a sample excel which contains the structure of csv file that I will import , and two other tables. I have given the expected output table as well.

    I have more than 100 tables with me and each table has different primary column. My requirement is to get the count of all primary columns of all the tables.

    Instead writing the count query 100 times, I am trying to achieve that in single query.

    Hope it clarifies.

    Thanks again

  • Just wondering, who is putting you up to something like this? I can see this going sideways very fast. Without understanding what you're really trying to achieve, I'm hesitant to offer advice (not that mine is worth any more than you pay for it, i.e., nothing.)

    Tons of tables? For a newbie? Scary thought. You can probably get all this information from the schema without much work at all.

    Read this link. Pinal's website is great... sometimes you gotta dig around, but learning is like that... you gotta earn it.

    http://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/

    http://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/

  • HI

    I have already visited that website and queried from information schema to get the list of all table names and column names. but that is not the requirement.

    Being a freebie, total no of tables doesn't matter. I just need the workable logic to query regardless of number of tables.

    Thanks for your response anyways.

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

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