将查到的数据插入一个自增编号的临时表

if exists(select name from sysobjects where name='autotemp' and type='u') begin drop table dbo.autotemp end//如果系统中有这张白表就先删除

SELECT id=IDENTITY(bigint,1,1),BB.* INTO dbo.autotemp FROM (//id为自增编号
select distinct top 2000
a.pk_id as ACCOUNT_ID,
233 as PROJECT_ID, //将233作为一列项目编号
a.busi_telareacode+a.busi_tel1 as TEL_NUM1,
a.busi_telareacode+a.busi_tel2 as TEL_NUM2,
a.busi_telareacode+a.busi_tel3 as TEL_NUM3,
(case when a.busi_telareacode<>'010' then '0'+a.busi_tel4 else a.busi_tel4 end) as TEL_NUM4
from hp_accounts a join (select account_pk,case_pk,visitor_pk from hp_assignment where case_pk = 233 ) ha
on a.pk_id = ha.account_pk left join hp_contacts f on a.pk_id = f.account_pk where ha.visitor_pk is null
and a.auto_flag <> '1' order by account_id

)BB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值