Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2012-06-21 : 05:37:27
|
Hi, I have the following codeSELECT dbo.qryPracExclude.prac_noFROM dbo.qryPracExclude LEFT OUTER JOIN dbo.TblPracExclude ON dbo.qryPracExclude.prac_no = dbo.TblPracExclude.prac_no qryPracExclude.prac_no = 1, 2, 3, 4 dbo.TblPracExclude.prac_no = 1, 2, 3The results of the above gives me prac_no 123I want the result to give me; prac_no 4this prac_no is present in qryPracExclude.prac_no and not dbo.TblPracExclude.prac_no. I tried <> instead of = but I receive duplicates and all prac_nos. Any help will be appreciated |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-21 : 05:54:01
|
| Your query shoould give all 4 values from qryPracExclude so I think there is something wrong with that.When you correct it.SELECT dbo.qryPracExclude.prac_noFROM dbo.qryPracExclude LEFT OUTER JOIN dbo.TblPracExcludeON dbo.qryPracExclude.prac_no = dbo.TblPracExclude.prac_nowhere dbo.TblPracExclude.prac_no is null==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2012-06-21 : 05:59:58
|
| Many thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-21 : 17:52:45
|
alsoSELECT q.prac_noFROM dbo.qryPracExclude qWHERE NOT EXISTS (SELECT 1 FROM dbo.TblPracExclude WHERE prac_no = q.prac_no) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|