Results 1 to 3 of 3

Thread: Getting records using the Triggers

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Getting records using the Triggers

    hi to all,
    i want get the updated records using the trigger. i am using the following query for that,


    create trigger updatetrigger ON testtable for UPDATE AS BEGIN Declare @Name nvarchar(50)
    Declare @age nvarchar(50)
    Declare @mailid nvarchar(50)
    Declare @phoenno nvarchar(50)
    Declare @datetime smalldatetime SELECT @Name = Name , @age = age , @mailid = mailid , @phoenno = phoenno , @datetime = datetime FROM INSERTED
    END



    my table testtable does not contain unique field.

    when i update the value in the testtable. the affected row is not stored in the testtable1. how can i solve the probems. plz help me . and also i need to get the records before updated . can i get the records using the update triggers. if anybody know plz help me.


    thank u

    with thanks and regards
    mmary

  2. #2
    Lively Member Shardox's Avatar
    Join Date
    Nov 2006
    Location
    Barcelona, Spain
    Posts
    123

    Re: Getting records using the Triggers

    I think you are storing the updated values into local variables inside the trigger and not doing anything with those variables afterwards. I think the following statement will return you the values you are looking for:

    Select Name,age, mailid,phoneno,datetime from inserted

    Then, if you want to get the old values you can get them inside the update trigger from the deleted table:

    Select Name,age, mailid,phoneno,datetime from deleted

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Resolved Re: Getting records using the Triggers

    thank u . thank u very much for ur reply.


    with thanks and regards
    mmary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width