Click to See Complete Forum and Search --> : sql query not getting correct results.


rizshe
09-13-2006, 07:19 AM
Hi ya,
I'm using sql server 2005. i have 2 tables in the database. 1) tbl_temp. 2) tbl_empDetails.
I have got 149 rows in tbl_temp and about 2 records in tbl_empDetails presently.
Both tables have got SID fileds which is a big string field.
These 2 records are identical to 2 records in tbl_temp. Basically i want to run a query which will bring me the records that are not matched to tbl_empDetails.
I have already run left outer join, right outer join but no luck.
Any ideas?

chazzy
09-13-2006, 07:55 AM
what makes them the same 2 rows?

CCCP
09-13-2006, 09:01 PM
Hi ya,
I'm using sql server 2005. i have 2 tables in the database. 1) tbl_temp. 2) tbl_empDetails.
I have got 149 rows in tbl_temp and about 2 records in tbl_empDetails presently.
Both tables have got SID fileds which is a big string field.
These 2 records are identical to 2 records in tbl_temp. Basically i want to run a query which will bring me the records that are not matched to tbl_empDetails.
I have already run left outer join, right outer join but no luck.
Any ideas?
try
SELECT *
FROM tbl_temp A
WHERE NOT EXISTS (SELECT * FROM tbl_empDetails B WHERE A.SID=B.SID)