注册 登录
编程论坛 SQL Server论坛

help----sql server 触发器

小白黑脸怪 发布于 2019-09-30 14:02, 1641 次点击
CREATE TRIGGER  [dbo].[tigger_update]
   ON  [UFTData231275_000002].[dbo].[SA_SaleDelivery]
   AFTER update
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    declare @saledeliveryorder nvarchar(50)
    select @saledeliveryorder=[SourceVoucherCode] from [UFTData231275_000002].[dbo].[SA_SaleDelivery]
    declare @id int
    select top 1 @id=[id]  FROM [UFTData231275_000002].[dbo].[SA_SaleOrder_b] order by [id] desc
    declare @saleorder nvarchar(50)
     select @saleorder=[code] from [UFTData231275_000002].[dbo].[SA_SaleDelivery] where [ID]= ( select [idSaleOrderDTO]  FROM [UFTData231275_000002].[dbo].[SA_SaleOrder_b] where [id]=@id)
    declare @s nvarchar(50)
    select  @s=[code] from [UFTData231275_000002].[dbo].[SA_SaleDelivery] where [SourceVoucherCode]=@saledeliveryorder
    update [UFTData231275_000002].[dbo].[SA_SaleOrder_b] set [priuserdefnvc1] =@s where [id]=@id
END
GO
创建数据库之后没什么就不能修改数据了
0 回复
1