I'm working on SQL Server to get the datas from one database and compare with another database. The database we have, has around 400's of table. I have to write a query to get all the table names based on the DB name, and having one column name, I have to get the datas from all the tables.
Still now, I have written a query to get the primary key value and to get the table names having that primary key value. My plan is to call the primary key details in first cursor, and within that create another cursor and fetch the details of the table name and column name.
Based on the values retrieved, I have to write a query to fetch the datas like "select * from @cursor_variable_tablename where primarykeyval = @cursor_variable_primarykeyval".
Is it possible to work like this by calling a variable instead of giving the table name.?
Please help me with this. Thanks In Advance.