临时表,select into,insert into select 使用

   SELECT
      [FORM_ID]
      ,identity(int,50,1) AS Line_No
      ,[BU]
      ,[WEBSITE]
      ,'Y' as [IS_ACTUAL_LINE]
      ,[CUSTOMER_TYPE]
      ,[CUSTOMER_GROUP]
      ,[CUSTOMER_NAME]
      ,[CUSTOMER_CODE]
      ,[REBATE_TYPE]
      ,[MODEL_VERSION]
      ,[PART_NO]
      ,[QTY]
      ,[CURRENCY]
      ,[AMOUNT]
      ,[EFFECTIVE_FROM]
      ,[EFFECTIVE_TO]
      ,[REMARK]
      ,[ACTIVE]
      ,[NOTE_ID]
      ,[NOTE_GROUP]
      ,[NOTE_CNAME]
      ,[NOTE_ENAME]
      ,[NOTE_DATE]
      ,[UPDATE_ID]
      ,[UPDATE_GROUP]
      ,[UPDATE_CNAME]
      ,[UPDATE_ENAME]
      ,[UPDATE_DATE]
into #t
FROM [BU].[dbo].[Invoice_Rebate_Customer_L]
where active='Y' and  form_id='2858';
set IDENTITY_INSERT [Invoice_Rebate_Customer_L] ON
insert into [Invoice_Rebate_Customer_L](
[FORM_ID]
      ,Line_No
      ,[BU]
      ,[WEBSITE]
      ,[IS_ACTUAL_LINE]
      ,[CUSTOMER_TYPE]
      ,[CUSTOMER_GROUP]
      ,[CUSTOMER_NAME]
      ,[CUSTOMER_CODE]
      ,[REBATE_TYPE]
      ,[MODEL_VERSION]
      ,[PART_NO]
      ,[QTY]
      ,[CURRENCY]
      ,[AMOUNT]
      ,[EFFECTIVE_FROM]
      ,[EFFECTIVE_TO]
      ,[REMARK]
      ,[ACTIVE]
      ,[NOTE_ID]
      ,[NOTE_GROUP]
      ,[NOTE_CNAME]
      ,[NOTE_ENAME]
      ,[NOTE_DATE]
      ,[UPDATE_ID]
      ,[UPDATE_GROUP]
      ,[UPDATE_CNAME]
      ,[UPDATE_ENAME]
      ,[UPDATE_DATE]
)
select * from #t;
drop table #t;
posted @ 2009-06-02 14:36  只想做好  阅读(725)  评论(0编辑  收藏  举报