Dynamically comparing two tables from two different databases and serves in SQL Server Management Studio -
i working on project, user select a table choice on website. once table selected, website connect database , select table server (server a) under database (abc). website have choose same table different server (server b) under database (def). these tables have same name, have different data entered them.
our goal come dynamic sql query/stored procedure. multiple table choices can visible in website , once user picks option, dynamically passes information database find 2 tables , yield final table portrays differences.
my problem:
- i having lot of problem syntax , doing process dynamically. have searched everywhere solution , struggling more 2 weeks.
outline of plan:
find primary keys , column names of columns in selected table. pass information temporary table
create sql query :
set @sql = select table1.col1, table2.col1... inner join..
take care of conditions :
a. data present in 1 table not other
b. data present in both tables
c. if there no data in 1 or both tables.
i appreciate help. new sql , have been trying hardest in project while. please me , best repay you. thank time.
Comments
Post a Comment