Need to update row in the table if any one of the value is getting updated

Hi All,
I am new to SQL, I need to update the table's row if any one of the value of the row is getting updated, if none of the value is updated then do nothing.
Advice requested

It is not clear what you meant... Perhaps a trigger 
CREATE TRIGGER ShowUpdatedColumns ON Test FOR UPDATE
AS
DECLARE @ColumnID int, @Columns nvarchar(4000), @ObjectID int, @LastColumnID int
SET @ObjectID=(SELECT id FROM sysobjects WHERE name='test')
SET @LastColumnID=(SELECT MAX(colid) FROM syscolumns WHERE id=@ObjectID)
SET @ColumnID=1
WHILE @ColumnID<=@LastColumnID BEGIN
IF (SUBSTRING(COLUMNS_UPDATED(),(@ColumnID - 1) / 8 + 1, 1)) &
POWER(2, (@ColumnID - 1) % 8) = POWER(2, (@ColumnID - 1) % 8)
SET @Columns = ISNULL(@Columns+',','') + COL_NAME(@ObjectID,@ColumnID)
SET @ColumnID=@ColumnID+1
END
PRINT 'Updated columns are :' + @Columns 
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • How can i update rows  in a table based on a match from a select query

    Hello
    How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
    Thanks Glenn
    table1
    attribute1 varchar2 (10)
    attribute2 varchar2 (10)
    processed varchar2 (10)
    table2
    attribute1 varchar2 (10)
    table3
    attribute2 varchar2 (10)
    An example:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)

    Hi,
    Etbin wrote:
    Hi, Frank
    taking nulls into account, what if some attributes are null ;) then the query should look like
    NOT TESTED !
    update table1 t1
    set processed = 'Y'
    where exists(select null
    from table2
    where lnnvl(attribute1 != t1.attribute1)
    and exists(select null
    from table3
    where lnnvl(attribute2 != t1.attribute2)
    and processed != 'Y'Regards
    EtbinYes, you could do that. OP specifically requested something else:
    wgdoig wrote:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
    But there is no argument about what needs to be done when processed is NULL.
    OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary.

  • Update Row into Run Table Task is not executing in correct sequence in DAC

    Update Row into Run Table Task is not executing in correct sequence in DAC.
    The task phase for this task is "Post Lost" . The depth in the execution plan is 19 but this task is running some times in Depth 12, some times in 14 and some time in Depth 16. Would like to know is this sequence of execution is correct order or not? In the out of the Box this task is executed at the end of the entire load. No Errors were reported in DAC log.
    Please let me know if any documents that would highlight this issue
    rm

    Update into Run table is a task thats required to update a table called W_ETL_RUN_S. The whole intention of this table is to keep the poor mans run history on the warehouse itself. The actual run history is stored in the DAC runtime tables, however the DAC repository could be on some other database/schema other than warehouse. Its mostly a legacy table, thats being carried around. If one were to pay close attention to this task, it has phase dependencies defined that dictate when this task should run.
    Apologies in advance for a lengthy post.... But sure might help understanding how DAC behaves! And is going to be essential for you to find issues at hand.
    The dependency generation in DAC follows the following rules of thumb!
    - Considers the Source table target table definitions of the tasks. With this information the tasks that write to a table take precedence over the tasks that reads from a table.
    - Considers the phase information. With this information, it will be able to resolve some of the conflicts. Should multiple tasks write to the same table, the phase is used to appropriately stagger them.
    - Considers the truncate table option. Should there be multiple tasks that write to the same table with the same phase information, the task that truncates the table takes precedence.
    - When more than one task that needs to write to the table that have similar properties, DAC would stagger them. However if one feels that either they can all go in parallel, or a common truncate is desired prior to any of the tasks execution, one could use a task group.
    - Task group is also handy when you suspect the application logic dictates cyclical reads and writes. For example, Task 1 reads from A and writes to B. Task 2 reads from B and writes back to A. If these two tasks were to have different phases, DAC would be able to figure that out and order them accordingly. If not, for example those tasks need to be of the same phase for some reason, one could create a task group as well.
    Now that I described the behavior of how the dependency generation works, there may be some tasks that have no relevance to other tasks either as source tables or target tables. The update into run history is a classic example. The purpose of this task is to update the run information in the W_ETL_RUN_S with status 'Completed' with an end time stamp. Because this needs to run at the end, it has phase dependency defined on it. With this information DAC will be able to stagger the position of execution either before (Block) or after (Wait) all the tasks belonging to a particular phase is completed.
    Now a description about depth. While Depth gives an indication to the order of execution, its only an indication of how the tasks may be executed. Its a reflection of how the dependencies have been discovered. Let me explain with an example. The tasks that have no dependency will have a depth of 0. The tasks that depend on one or more or all of depth 0 get a depth of 1. The tasks that depend on one or more or all of depth 1 get a depth of 2. It also means implicitly a task of depth 2 will indirectly depend on a task of depth 0 through other tasks in depth 1. In essence the dependencies translate to an execution graph, and is different from the batch structures one usually thinks of when it comes to ETL execution.
    Because DAC does runtime optimization in the order in which tasks are executed, it may pick a task thats of order 1 over something else with an order of 0. The factors considered for picking the next best task to run depend on
    - The number of dependent tasks. For example, a task which has 10 dependents gets more priorty than the one whose dependents is 1.
    - If all else equal, it considers the number of source tables. For example a task having 10 source tables gets more priority than the one that has only two source tables.
    - If all else equal, it considers the average time taken by each of the tasks. The longer running ones will get more preference than the quick running ones
    - and many other factors!
    And of course the dependencies are honored through the execution. Unless all the predecessors of a task are in completed state a task does not get picked for execution.
    Another way to think of this depth concept : If one were to execute one task at a time, probably this is the order in which the tasks will be executed.
    The depth can change depending on the number of tasks identified for the execution plan.
    The immediate predecessors and successor can be a very valuable information to look at and should be used to validate the design. All predecessors and successors provide information to corroborate it even further. This can be accessed through clicking on any task and choosing the detail button. You will see all these information over there. As an alternate method, you could also use the 'All/immediate Predecessors' and 'All/immediate Successor' tabs that provide a flat view of the dependencies. Note that these tabs may have to retrieve a large amount of data, and hence will open in a query mode.
    SUMMARY: Irrespective of the depth, validate
    - if this task has 'Phase dependencies' that span all the ETL phases and has a 'Wait' option.
    - click on the particular task and verify if the task does not have any successors. And the predecessors include all the tasks from all the phases its supposed to wait for!
    Once you have inspected the above two you should be good to go, no matter what the depth says!
    Hope this helps!

  • How to find newly updated rows in a table

    Hi..
    How to know newly updated rows in a table.
    Thanks in advance
    pal

    Or other good thing would be to add LAST_UPDATED column to your table, that can reflect the time the row gets updated.
    G

  • Fetching more than one row from a table after selecting one value from the dropdown

    Hi Experts,
    How can we fetch more than one row from a table after selecting one value from the dropdown.
    The scenario is that I have some entries in the dropdown like below
      A               B               C        
    11256          VID          911256  
    11256          VID          811256
    11256          SONY      11256
    The 'B' values are there in the dropdown. I have removed the duplicate entries from the dropdown so now the dropdownlist has only two values.for eg- 'VID' and'SONY'. So now, after selecting 'VID' from the dropdown I should get all the 'C' values. After this the "C' values are to be passed to other methods to fetch some data from other tables.
    Request your help on this.
    Thanks,
    Preeetam Narkhede.

    Hi Preetam!
    I hope I understand your request proberly, since this is more about Java and less about WebDynpro, but if I'm wrong, just follow up on this.
    Supposed you have some collection of your original table data stored in variable "origin". Populate a Hashtable using the values from column "B" (let's assume it's Strings) as keys and an ArrayList of whatever "C" is (let's assume String instances, too) as value (there's a lot of ways to iterate over whatever your datasource is, and since we do not know what your datasource is, maybe you'll have to follow another approach to get b and c vaues,but the principle should remain the same):
    // Declare a private variable for your Data at the appropriate place in your code
    private Hashtable temp = new Hashtable<String, ArrayList<String>>();
    // Then, in the method you use to retrieve backend data and populate the dropdown,
    // populate the Hashtable, too
    Iterator<TableData> a = origin.iterator();
    while (a.hasNext()) {
         TableData current = a.next();
         String b = current.getB();
         String c = current.getC();
         ArrayList<String> values = this.temp.get(b);
         if (values == null) {
              values = new ArrayList<String>();
         values.add(c);
         this.temp.put(b, values);
    So after this, you'll have a Hashtable with the B values als keys and collections of C values of this particular B as value:
    VID --> (911256, 811256)
    SONY --> (11256)
    Use
    temp.keySet()
    to populate your dropdown.
    After the user selects an entry from the dropdown (let's say stored in variable selectedB), you will be able to retrieve the collection of c's from your Hashtable
    // In the metod you handle the selection event with, get the c value collection
    //and use it to select from your other table
    ArrayList<String> selectedCs = this.temp.get(selectedB);
    // now iterate over the selectedCs items and use each of these
    //to continue retrieving whatever data you need...
    for (String oneC : selectedCs) {
         // Select Data from backend using oneC in the where-Clause or whatever...
    Hope that helps
    Michael

  • HT4623 I'm trying to update my iPhone 5 to IOS 7 through iTunes. I get a pop up saying I need to update my iTunes to  11.0.5 before I can update my iPhone. The problem is my iTunes is current, and no update for iTunes is found. Any one have any suggestion

    I'm trying to update my iPhone 5 to IOS 7 through iTunes. I get a pop up saying I need to update my iTunes to  11.0.5 before I can update my iPhone. The problem is my iTunes is current, and no update for iTunes is found. Any one have any suggestions?

    I had the same problem. My phone wasn't finding it so I tried plugging it into my laptop and it said I needed the latest iTunes which I already had.... I unplugged my phone from my laptop and did a soft reset to my phone (hold down the lock button and home button at the same time until your phone turns off) once it turns back on you should find the update... Click general... Software update. Worked for me!

  • Saving the table content into one excel sheet

    Hello,
    I have got following problem:
    I'm measuring data with a DAQ card. I'm interested in the min and max value of the measured data. Therefore I'm using the Amplitude and Level measurent function. Its no problem to display the results in the graphical interface. What causes me trouble is to save the content of the displayed table into some kind of file. Anybody know a solution?
    Thanks!

    The problem is that I use the descriped min/max function. If I write it to a text file I get a lot of additional information every second.
    Following example shows what is written to the measurement file:
    Channels 6      
    Samples 1 1 1 1 1 1 
    Date 2010/03/05 2010/03/05 2010/03/05 2010/03/05 2010/03/05 2010/03/05 
    Time 14:26:48.9938435554504394532 14:26:48.9938435554504394532 14:26:48.9938435554504394532 14:26:48.9938435554504394532 14:26:48.9938435554504394532 14:26:48.9938435554504394532 
    Y_Unit_Label Volts Volts Ampere Ampere Ampere Volts 
    X_Dimension Time Time Time Time Time Time 
    X0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 
    Delta_X 0.001000 0.001000 0.001000 0.001000 0.001000 0.001000 
    ***End_of_Header***       
    X_Value U_1 (Positive Peak) U_2 (Positive Peak) I_3(Positive Peak) I_1 (Positive Peak) I_2 (Positive Peak) U_3(Positive Peak) Comment
    0.000000 3.461911 3.189588 0.115779 2.103480 0.739258 1.206654
    This kind of information is not displayed if I visualize it in a table. The table only shows me the time and the corresponding min/max values. These values are updated every second.
    I tried to write it to a spreadsheet,  this approach was also not successful since a new spreadsheet was opened/generated every second respectively every time a new min/max value was aquired.
    I would like to safe the data fro, the table to a file without the additionál information showed above in the example.
    Thanks!

  • In MS Word, it is possible to prevent tables from breaking at page breaks.  So, if a table, when populated with data gets too big for the spae allotted on one page, the table will move in its entirety, to the next page. Can this be done in "Pages"?

    I am trying to figure out ow to prevent tables from breaking along a row when there is a page break in "Pages".  This is done in MS Word by going under Table properties under "Rows".   I have a document with small three row tables and I want to keep the tables together and move to the next page in its entirety when there is a page break.  Help!

    The table that I don't want to break between rows looks like this, except it fits the width of the page:
    quilt name
    picture of quilt      
    source
    Size: XX; Difficulty Level: 3
    I inserted a Inline Text box into the document, copied the table inside the text box, then pasted it through the document (which lists quilting projects).  When the table spans a page break, even when in an inline text box, the picture which is in the right hand column splits, as well as the information pertaining to the particular quilt.
    Jerry - thank you for your help.  I tried to give you a "solved my problem" rating, but I am adjusting to the Mac slowly after 20+ years on a PC.

  • In Pages, the column in the table won't flow onto the second page. The text is hidden. Please help!

    In Pages, the column in the table won't flow onto the second page. The text is hidden. Please help!

    Thank you for your reply,
    When I click 'view' , I can "show inspector". From the table tab, I can pull up the "Format". [See below]. I don't see the "Arrange" or "Object Placement Move with Text"
    Right now I have the Wrap Text On. When I take it off, It messes up my rows [see second image].
    All I want is for my column to flow onto the second page.
    Your assistance is genuinely appreciated.
    Thank you again.

  • What are the tables for Partner Fuction regarding the Vendors Purchasing ?

    Hello Gurus,
    What are the tables for Partner Fuction regarding the Vendors Purchasing Organisation. I need the Partner Function Key, Parner Function Name, Number and the Name of the Number.
    Thanx in advance,
    Ramona

    Hi Jürgen,
    I know that table but it is only showing me the technical name of the Partner Function and I need also the rest: the text(name), number and the number name (text). I presume there are other tables for those infos.
    I am not sure if I understand what are these. I just want the table to upload the data to BW.

  • Hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?, hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?

    hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?, hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?

    The only people who can possibly assist you with this is Apple Customer Relations, call your local Apple contact number and ask for Customer Relations then explain your situation clearly and politely (be firm but don't rant).
    You might want to investiage what the local laws are regarding defective goods and 'fit for use' definitions on warranties etc. Consumer Protection can be a useful tool to use or bargain with if needed ...

  • I have a 2005 Jaguar xj8.  When I tried to upgrade my 3gs to a 4g I got a ticking noise in the speaker and no one on the other end could hear me.  I had to go back to a 3gs.  My phone is shot and I need to upgrade.  Has there been a fix to the problem?

    I have a 2005 Jaguar xj8.  When I tried to upgrade my 3gs to a 4g  two years ago, I got a ticking noise in the speaker and no one on the other end could hear me.  I had to go back to a 3gs.  My phone is shot and I need to upgrade.  Has there been a fix to the problem?  Apple told me there was some sort of interference with the airbag system.  Jaguar was totally unhelpful.

    Hi Labjock,
    Welcome to the Support Communities!
    The article below may be able to help you with this. 
    iPhone: Microphone issues
    http://support.apple.com/kb/ts5183
    Cheers,
    - Judy

  • New problem! When I sync my iPhone 5s to Outlook the events entered in my phone Calendar do not get updated to my outlook calendar on my laptop yet entries on entered on my outlook calendar do get updated to my phone??

    New problem! When I sync my iPhone 5s to Outlook the events entered in my phone Calendar do not get updated to my outlook calendar on my laptop yet entries on entered on my outlook calendar do get updated to my phone??
    iPhone 5s
    Software - IOS 8.1
    iTunes - v12
    I have been using sync on all previous phones to date without issue, I have had the 5s since Nov 2014 and no issue, on Sunday without warning or changes to my phone or Outlook sync now has this error.
    I have restored my phone but still has same problem.

    Your IT person is an idiot.
    http://lmgtfy.com/?q=how+to+sync+iphone+with+outlook

  • When converting tables in a MS Word 2010 or 2007 to PDF the table borders do not retain the correct thickness as identified in the word document.  Is there a solution for this issue?

    When converting tables in a MS Word 2010 or 2007 to PDF the table borders do not retain the correct thickness as identified in the word document.  Is there a solution for this issue?

    Please try with latest version of MS Word and Acrobat.
    Regards,
    Anoop

  • Can any one share the Oracle Reports 6i Developer demo table scripts?

    Hi,
    I have to learn the Report 6i for my office project, I have installed the report 6i developer but I could not get the Demo CD, can any one share the Scripts for table (viz. Stock, stock_history , indcat ) creation and also the insert script for data population or provide the URLs where I can find the same.
    thanking you in advance.
    regards,
    Sham.

    Hi Denis,
    Thanks for the reply, I have the setup for forms and reports 6i, what i was looking is the script to create the tables used in the
    Oracle® Reports Developer
    Building Reports
    Release 6i
    January, 2000
    Part No. A73172-01
    the table names are stocks, indcat etc, generally these demo script come along with the demo CD provided by oracle as i don't have the CD i am looking for these table creation script. if you have these scripts kindly share the same with me.
    regards,
    Sham.

Maybe you are looking for