The issue that I am running into is happening on Microsoft SQL Server.
I have a view that is unioning together 2 tables. It is returning a little over 7 million records.
When I attempt to JOIN together the view with another table on one column I am getting an error: "Conversion failed when converting the varchar value 'www.com' to data type int" Example code:
SELECT ColumnA, ColumnB, …, ColumnZ FROM Table1 UNION ALL SELECT ColumnA, ColumnB, …, ColumnZ FROM Table2
This SELECT is returning a Conversion failed error:
SELECT * FROM View_A (NOLOCK) INNER JOIN Table3 (NOLOCK) ON View_A .ColumnA = Table3.ColumnA
The ColumnA’s in all three tables are of type INT.
If I do one of the following, I get no errors:
SELECT * INTO #TempTable FROM ViewA (NOLOCK)and then do the JOIN on Table3
SELECT * FROM View_A (NOLOCK) INNER JOIN Table3 (NOLOCK) ON TRY_CAST(View_A .ColumnA AS INT) = Table3.ColumnA
Any ideas on what is happening and how to fix would be greatly appreciated.