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

    How to check updated column name in SQL

    Hi all

    I have 2 SQL table with same structure as below

    Table 1

    ENo Ename Gender

    1 ABC M


    Table 2

    ENO Ename Gender

    1 XYZ M

    in the above table how can i find out different value column .this case Ename column having different value. so result must be Ename.

    let me know the sql query to implement this logic


    Regards

    Saravana
  • #762148
    Hello Sarvana Perumal,

    You can use Triggers. Refer about the same on MSDN Code Library on below mentioned link :

    https://msdn.microsoft.com/en-us/library/ms189799.aspx

    https://msdn.microsoft.com/en-us/library/cc280519(v=SQL.100).aspx


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762149
    Hi

    You can try this Query


    Select Ename from Table1 where Ename<>
    (Select Ename from Table1)

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762173
    Hi

    You can use update trigger to find the modified columns in your table.

    Refer below links where you can find solution for your query.

    http://www.sqlservercentral.com/Forums/Topic504916-338-1.aspx

    http://stackoverflow.com/questions/1254787/sql-server-update-trigger-get-only-modified-fields

    http://sqlmag.com/t-sql/identifying-modified-columns-puzzle

    Regards

    Sridhar Thota.

    Sridhar Thota.
    Editor: DNS Forum.

  • #762196
    Hi

    Thanks for your reply.. Got Code for this.. here by I post


    declare @action_field varchar(max)

    SELECT @action_field = Isnull(@action_field + ', ', '') + name
    FROM syscolumns
    WHERE id = (select object_id from sys.tables where name = 'tablename)
    AND CONVERT(VARBINARY, Reverse(Columns_updated())) & Power(CONVERT(BIGINT, 2), colorder - 1) > 0




    The above code capture the updated column value with comma separated value.

    Thanks & Regards
    --------------------
    Saravana Perumal.N


Sign In to post your comments