创建要更新的触发器

时间:2016-11-13 03:49:29

标签: sql-server tsql sql-server-2012 database-trigger

我正在尝试创建一个触发器,为正在更新的行填充列。这是我做的,但它不起作用:

<body ng-app="TravelApp" ng-controller="Controller" class="">

<div class="centering-container">
    <div class="material-container">
        <div class="padding-25">
            <form class="form" role="search" method="get">
                <div class="input-group">
                    <input type="text" class="form-control"     placeholder="Search" ng-model="searchTerm">
                    <div class="input-group-btn">
                        <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
                    </div>
                </div>
            </form>
            <div style="padding-top:25px;">
                <button ng-click="getData()" type="button" class="material-button ">Lets Go!</button>
            </div>
        </div>
    </div>


</div>
<div class="container-fluid" id="package-container">
    <div class="row">
        <div class="col-sm-6 col-md-4" ng-repeat="p in packageList | filter : searchTerm">
            <div class="thumbnail">
                <img ng-src="{{p.packageImageLocation}}" alt="PackageImage">
                <div class="caption">
                    <h3>{{p.packageTitle}}</h3>
                    <p>{{p.packageLocation}}</p>


                </div>
            </div>
        </div>

    </div>


</div>

任何想法我可能做错了什么?

1 个答案:

答案 0 :(得分:1)

我认为这就是你要找的东西

CREATE TRIGGER PSL_Cases_Address
ON dbo.PSL_Cases
AFTER INSERT, UPDATE
AS
 BEGIN
  IF UPDATE(Permit_No) /*If column not affected skip*/
    BEGIN

        UPDATE PSL_Cases

        SET PSL_Cases.[address] = permits.[address] 

        FROM inserted INNER JOIN PSL_Cases ON 

               inserted.[Permit_No] = PSL_Cases.[PermitsID]

         INNER JOIN permits

        ON inserted.[Permit_No] = Permits.[PermitsID]            

    END
END;