clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36252 in the last week).

create table Employee (EmployeeNo int, EmpName varchar(50)); insert into Employee values (1, 'a'), (2, 'b'), (3, 'c'); create table WorkRecord2 (id int, EmployeeRun int, Company int, [date] date); insert into WorkRecord2 values (1, 1, 1, '2013-05-06'), (2, 2, 1, '2013-05-06') , (3, 3, 1, '2013-05-07');
6 rows affected
 hidden batch(es)


WITH cte AS ( SELECT w.EmployeeRun FROM WorkRecord2 w WHERE EXISTS (SELECT 1 FROM Employee WHERE EmployeeNo = w.EmployeeRun) AND w.Company = 1 AND w.date = '2013-05-06' ) DELETE FROM cte
2 rows affected
 hidden batch(es)


SELECT * FROM WorkRecord2
id EmployeeRun Company date
3 3 1 2013-05-07
 hidden batch(es)