我有表psc_Pro_ProfessorPositions(ProfessorID,PositionID,StartDate,EndDate)。它有2個主鍵是ProfessorID,PositionID。在一張表中檢查2個主鍵
我要檢查ProfessorID,PositionID不表insert.I寫這樣的:
INSERT INTO CoreUIs.dbo.psc_Pro_ProfessorPositions ( ProfessorID,PositionID,起始日期,結束日期 )
select a.MaQuanLy,b.MaQuanLy,convert(smalldatetime,NgayHieuLuc),convert(smalldatetime,NgayHetHieuLuc)
from inserted
inner join GiangVien a on a.MaGiangVien = inserted.MaGiangVien
inner join ChucVu b on b.MaChucVu = inserted.MaChucVu
where a.MaQuanLy not in (select ProfessorID from CoreUIs.dbo.psc_Pro_ProfessorPositions)
and b.MaQuanLy not in (select PositionID from CoreUIs.dbo.psc_Pro_ProfessorPositions)
但它是錯的。可以幫我嗎?謝謝大家。
它不是完全清楚什麼你在做。你的兩個表似乎具有相同的結構。如果你向我們展示了你已經嘗試過的SQL,這將會有所幫助。 – Jason 2012-02-15 03:39:43
有人按照stackoverflow標準格式化問題...我沒有權利這麼做:( – 2012-02-15 03:46:51
我相信'70100G07.000051 | CD09CKM1 | CNC102040 | 90'應該是'70100G07.000051 | CD09CKM1 | CNC102040 | NULL '...首先應該是NULL,第二個應該是90 ... – 2012-02-15 03:49:50