X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109 Path: csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!xlned.com!feeder1.xlned.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!198.186.194.249.MISMATCH!news-out.readnews.com!transit3.readnews.com!postnews.google.com!o7g2000prn.googlegroups.com!not-for-mail From: migurus Newsgroups: comp.databases.ms-sqlserver Subject: Re: update field with the same value Date: Fri, 11 Feb 2011 11:14:55 -0800 (PST) Organization: http://groups.google.com Lines: 49 Message-ID: <37015ddb-d725-40d9-b5e9-218144f2b08d@o7g2000prn.googlegroups.com> References: NNTP-Posting-Host: 66.18.138.24 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297451695 31187 127.0.0.1 (11 Feb 2011 19:14:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 11 Feb 2011 19:14:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o7g2000prn.googlegroups.com; posting-host=66.18.138.24; posting-account=PG2dbQkAAADVILsQ0GhgAM6hZK18SIjs User-Agent: G2/1.0 X-HTTP-Via: 1.1 TSSWF.tsswireless.com:8080 (http_scan/4.0.2.6.19) X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe) Xref: csiph.com comp.databases.ms-sqlserver:1597 On Feb 11, 12:54=A0am, Erland Sommarskog wrote: > migurus (migu...@yahoo.com) writes: > > -- we need to change quantity to 0 on row with CID=3D2 > > -- app produces this sql: > > > update #T > > set CID=3D3,DT=3D'20110210 12:30',QTY=3D0 > > where CID=3D3 > > > 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 fo= r > 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 i= s > generating the SQL, it could make the effort to generate an UPDATE statem= ent > with only the columns that changes. Then again, that's an extra complexit= y > 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, esq...@sommarskog.se > > Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodt= echnol/sql/2005/downloads/books... > Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/= previousversions/books.mspx The app does use parameterised statement, not inline values, I put that sql in my original post just to illustrate the situation. To see all pros and cons (complexity, extra effort, etc) I'd like to undesrtand is SQL Server smart not to update columns whose value was not changed? Thanks in advance!