Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2005 如何在SQLServer2005中编写插入触发器?_Sql Server 2005 - Fatal编程技术网

Sql server 2005 如何在SQLServer2005中编写插入触发器?

Sql server 2005 如何在SQLServer2005中编写插入触发器?,sql-server-2005,Sql Server 2005,您好,我想创建一个插入触发器,我必须将其表化 表硬件管理员 hardwareid hardwarename quantity 1 HDD 5 and second table 2 RAM 2 表1-1详细信息 transid hardwareid 1 1 2

您好,我想创建一个插入触发器,我必须将其表化

表硬件管理员

 hardwareid     hardwarename      quantity
     1             HDD              5          and second table
     2             RAM              2
表1-1详细信息

  transid        hardwareid
     1               1
     2               1
     3               1
     4               1
     5               1
     6               2
     7               2

在这里,我想创建一个触发器,一旦值进入hardwaremaster,它就会更新表transdetails。那么如何将触发器写入到它中

这可以帮助您:

 CREATE TRIGGER TR_INS_WhatYouWant
    ON hardwaremaster
    AFTER INSERT
    AS
    DECLARE @hardwareid  INT
    SELECT @hardwareid  = hardwareid  FROM inserted
    GO

    INSERT INTO dbo.transdetails (hardwareid) VALUES (@hardwareid)
但我建议在使用触发器之前阅读以下内容: