First, my apologies for the somewhat cryptic title.
I have imported 1000 sample rows from various tables in a SQL server (lets call it SQLSever1).
I have imported the rows into the second SQL Server(SQLServer2).
When I execute the following query on SQLServer2 I get no results, however when I execute the same query on SQLServer1 I get the expected results.
This is because I haven't imported all the rows from SQLServer1 to SQLServer2.
The problem is that I can't import all the data from SQLServer1 to SQLServer2 because some tables contain over 3 million rows.
Therefore, can someone let me know if there is a way to find out exactly data is required from the tables in SQLServer1 to get a result from SQLServer 2?
Basically, I need to import only those rows into SQL Server 2, that will produce the same result in SQL Server 1.
I believe I would need to do apply somekind of DISTINCT clause or a LEFT / RIGHT JOIN to determine the rows/fiels/data that is present in SQL Server 1 that is not present in SQL Server 2, but I'm not sure
.
The code is a follows:
SELECT Make.MakeName, Model.ModelName, Stock.Cost
FROM Data.Stock INNER JOIN Data.Model ON Model.ModelID = Stock.ModelID INNER JOIN Data.Make ON Make.MakeID = Model.MakeID
Sample data is follows:
CREATE TABLE #tmpTable (
MakeName nvarchar(100),
ModelName nvarchar(150),
Cost money)
INSERT #tmpTable VALUES
(N'Ferrari',N'Testarossa',52000.00),
(N'Ferrari',N'355',176000.00),
(N'Porsche',N'911',15600.00),
(N'Porsche',N'924',9200.00),
(N'Porsche',N'944',15960.00),
(N'Ferrari',N'Testarossa',176000.00),
(N'Aston Martin',N'DB4',23600.00),
(N'Aston Martin',N'DB5',39600.00)
SELECT * FROM #tmpTable
Any thoughts please