dwilliscp (5/9/2013)
The only things I left out was the listing of columns and the complete name (liked server.database.dbo.table), and the WHERE includes a limit on the #delivery... "Where #Delivery.Load_From = 'Something' ".I am not sure why I did not find this yesterday... but when I run the following query today I find two records:
select *
from details_2
where cast(delivery_doc as int) = 83535308
so now I get to find out why there are two records here .. that look the same.
Do you have more than one schema in your database? If there are tables named [details_2] in more than one schema, the fact that you have used an unqualified table name means that SQL Server may be resolving the table name to a schema other than the one you expect.
Jason Wolfkill