insert into Tongj_Item
select '2061855','admin', case String_tongjlb
when '1' then 'haha'
else 'hehe'
end
,str_LeibMingc,'admin',1,getdate()
from tj_gongzltj
group by String_tongjlb,str_LeibMingc
在sql编程中尽量减少使用游标,可直接将搜出的数据插入表,结合case,group等语句控制内容,可以避免主键重复。
浙公网安备 33010602011771号