Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,114 of 19,505    |
|    Erland Sommarskog to migurus    |
|    Re: update field with the same value    |
|    11 Feb 11 08:54:39    |
      f7264981       From: esquel@sommarskog.se              migurus (migurus@yahoo.com) writes:       > -- we need to change quantity to 0 on row with CID=2       > -- app produces this sql:       >       > update #T       > set CID=3,DT='20110210 12:30',QTY=0       > where CID=3       >       > My question - how bad is it? in real tables some colums are indexed,       > does it make server to try to modify indexes? Is SQL Server smart not       > to update columns whose value was not changed?              If this reflects the actual SQL - save the temp table - it is bad, but for       another reason than you ask about.              The app should produce parameterised SQL and not inline values, but maybe it       does in real life?              As for updating each column, even if unchanged... Since the application is       generating the SQL, it could make the effort to generate an UPDATE statement       with only the columns that changes. Then again, that's an extra complexity       and it could introduce bugs. And if you have stored procedures, you       typically have a procedure that accepts parameters for all columns.              So, all in all, not too much to be worried about - as long as it is       parameterised.              --       Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se              Books Online for SQL Server 2005 at       http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx       Books Online for SQL Server 2000 at       http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca