Re: is there a better way to do this???

From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 01/20/05


Date: Wed, 19 Jan 2005 21:30:35 -0600

The best answer depends on what you are trying to accomplish. TOP is
meaningless without ORDER BY. Any arbitrary row may be returned. Perhaps
the example below is what you are looking for?

UPDATE mytable
SET
    field1=MAX(field1),
    field2=MAX(field2),
    field3=MAX(field3)
FROM inserted

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"jose g. de jesus jr mcp, mcdba" <jose g. de jesus jr mcp, 
mcdba@discussions.microsoft.com> wrote in message 
news:A48851D0-646B-4B9A-84C3-CABE22174B14@microsoft.com...
> update mytable
> set field1=(select top 1 field1 from inserted),
> set field2=(select top 1 field2 from inserted),
> set field3=(select top 1 field3 from inserted)
>
> --thanks!!! 


Relevant Pages

  • RE: Users and Truncate Table
    ... Jose de Jesus Jr. ... MCP #2324787 ... >> Sykes Asia (Manila philippines) ...
    (microsoft.public.sqlserver.security)
  • RE: Create table rights
    ... DB_DDLADMIN rights to the database. ... "Jose G. de Jesus Jr MCP, ... > Jose de Jesus Jr. ...
    (microsoft.public.sqlserver.security)
  • Re: Bubba Betrays the Troops
    ... >>> That would be 'Resistance to change' again. ... >>> Jesus the researchers could have saved their time and just ... Maybe you and Jose No Se should join up and form Johnnie and Jose ... You only continue to spin your own blather and idiocy! ...
    (alt.politics.bush)
  • RE: SELECT Command - For beginner.
    ... Jose de Jesus Jr. ... Data Architect ... Sykes Asia ...
    (microsoft.public.sqlserver.datamining)
  • opening port 1433 to the web
    ... Jose de Jesus Jr. ... Sykes Asia (Manila philippines) ... MCP #2324787 ...
    (microsoft.public.sqlserver.security)