I am running 1 query against SQL Server 2005 and Its taking too much time to return and Eating up all the CPU. The problem with the SQL is we have 2 different database on 1 server and doing a Join and query looks something like this...
and seems like A.TNId = B.NPA + B.DBB + B.RDV is causing all the trouble.
Can someone recommend any better approach to handle this without making changes to db structure? B is really big table with some million records in it.
Select Distinct TNid from db1.dbo.Table A , Db2.dbo.Table1 B where
A.CreateDate > b.CreateDate
And A.TNId = B.NPA + B.DBB + B.RDV