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等语句控制内容,可以避免主键重复。
Posted on 2005-12-14 12:06  Blue  阅读(286)  评论(0)    收藏  举报