mergemerge into copy_emp ce using emp e on (ce.empno = e.empno) when matched then update set ename = e.ename when not matched then insert (empno, ename) values(e.empno, e.ename) 注: merge 也属于 dml 操作, 所以操作之后需要进行 commit; escape 转义字符SELECT * FROM copy_em
declare @num1 int --为符合条件的总行数 select @num1=COUNT(1) from cardInfo where openDate between @date1 and @date2 [email protected] 和 @date2 为开始时间到结束时间,可以理解一个条件 while(@num1<>0) --和下面的[email protected]=1形成循环的次数begin print @num1