You must Sign In to post a response.
  • Category: SQL Server



    i want to write trigger in sqlserver 2008 . how to write

    and i want a trigger for a table such that

    Write a stored procedure in PL/SQL that accepts the registration number of a vehicle and determines if the vehicle is available. The answer can be 'True' or 'False' and should be returned as a parameter.

    (ii) The value of the car_returned field of the Hire table can be 'True' or 'False'.

    Write a trigger in PL/SQL that updates the Vehicle table with the current location of the car when the car is returned and the car_returned field is changed to 'True'.
  • #572530
    You can write a Stored Procedure as per your requirement. Please check the follwoing code:

    CREATE PROCEDURE CheckExist @VechicelNo INT, @IsExist BIT OUT
    DECLARE @Count INT
    SELECT @Count = COUNT(*) FROM TblVechicle WHERE VechicelNo = @VechicelNo
    SET @IsExist = 0
    IF @Count>=1
    SET @IsExist = 1

    Thanks & Regards
    Paritosh Mohapatra
    Microsoft MVP (ASP.Net/IIS)
    DotNetSpider MVM

  • #572531

    Try to understand the concept of triggers and learn on your own.

    You need to try it on your own and if you have any issues in the query post the query we will correct it. Please try to learn and frame the stored procedure. It will help you in future. You cannot always depend on some others. Try to do it by yourself.

    Check the below link for the sample triggers.

    Thanks & Regards
    D.Jeya Kumar(JK)

  • #572548
    A trigger is a block of code that constitutes a set of T-SQL statements that are activated in response to certain actions or conditions.

    A trigger can also be interpreted as a special kind of stored procedure that is executed whenever an action,such as data modification,takes place.

    A Trigger is fired whenever data in the underlying table is affected by any of the Data Manipulation Language (DML) statements -INSERT,UPDATE,OR DELETE.

    Triggers help in maintaining consistent,reliable,and correct data in tables.They enable the performance of complex actions and cascade these actions to other dependent tables.

    Thanks & Regards


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.