Sql Server儲存過程從一個表中抓取資料填充到另一張表中
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <alex,,Name>
-- Create date: <2011-9-20,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[ToCrmIvNumProd]
(
@ItemOneNo varchar(30)
)
AS
BEGIN
declare @prodNo varchar(30)
declare @ivnum numeric(17,8)
select @prodNo=itemno,@ivnum=qty from uv_validstock where
if exists(select itemno from crm_iv_middle_tb where
[email protected])
begin
if @prodNo !=''
begin
update crm_iv_middle_tb set
[email protected],[email protected] where [email protected]
end
end
else
begin
if @prodNo != ''
begin
insert into crm_iv_middle_tb(itemno,ivnum) values(@prodNo,@ivnum)
end
end
END