
用下面这句
select s.name from student s where s.Name in (select i.Name from inserted)
是这样的,insert into...values...语句不允许和where子句一起使用的(子查询追加insert into...select...则可以在子查询里使用where子句)。要实现题主的这个需求,只能通过应程序端编程或在数据库端的存储过程里解决。
补充回答
后来我尝试了一下用 insert into...select..变通一下单凭SQL也可以解决,我在ACCESS里测试这个思路通过了。由于身边没有MSSQL环境,请题主测试下列代码,我想应该也是可以的
insert into tbTeam_daily selecttop 1 N'2011-12-2',N'3组',N'',N'23' from tbTeam_daily
where not exists (select 1 from tbTeam_daily
where tdate = N'2011-12-2' and teamName = N'4组')
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)