Update in SQL

Hi all

I have a table table1, contains data for the last 3 quarters.
There act_nbr, neighborhood, p_date as columns.
Act_nbr is the primary key and quarter a 201003,201006,201009 values.
p_date is the date of the perfect doc.

I have changed the table1, added 2 new columns p_date_max, p_date_min.

update the table table1: for p_date = 201006,.

I wrote

setting a day of table1 set p_date_max = (select max (p_date) from table1
where p_date in (201003,201006)
and a.act_nbr = b.act_nbr)
where a.p_date = 201006;

his is a long time to run, then I took an act_nbr and tested the result and it seems as expected but I need optimize the query.

Is there a better way of writing, the update?

Thank you

Try using the fusion

Merge into table1 a
using
(
     select max(p_date) as max_dt, act_nbr
     from table1
     where p_date in (201003,201006)
     group by act_nbr
)b
on ( a.act_nbr=b.act_nbr and a.p_date = 201006)
when matched set a.p_date_max = b.max_dt 

Thank you...

Tags: Database

Similar Questions

  • update of sql server 2005 service pack 3 error code 6D9E Windows update security does not accept the update

    update of sql server 2005 service pack 3 error code 6D9E Windows update security does not accept the update

    Hey lasdj,

    Thanks for posting in the Microsoft answers site!

    If you receive Windows Update error 6d9e while installing SQL Server 2005 Service Pack 3 by using Windows Update, it means that the installation folders and directories are compressed or encrypted.

    To fix this problem, make sure the folder locations where you are installing the service pack to aren't compressed or encrypted, or specify a different folder and then run Windows Update again.

    Therefore, remove the compression of the DATA directory and run together to the top again.

    Remove compression from the C:\Program Files\Microsoft SQL Server folder and see if you are able to install the updates without any problem.

    See the links below for more details:

    Windows Update error 6d9e
    http://Windows.Microsoft.com/en-IE/Windows-Vista/Windows-Update-error-6D9E 

    Install SQL Server 2005 and 2008 failures (compressed DATA directory)
    http://blogs.msdn.com/psssql/archive/2009/02/24/SQL-Server-2005-and-2008-Setup-failures-compressed-data-directory.aspx

    I hope this helps!
    Gokul T - Microsoft Support

  • A security update for SQL Server 2005 Service Pack 3 (KB970892) could not istall

    "A security update for SQL Server 2005 Service Pack 3 (KB970892) istall failure."

    I'm not sure if this is the right place to post this but I hope I can get help.
    I can't get the update mentioned above to install after several attempts. Have searched the knowledge base and tried various suggestions of solutions without success.
    If anyone has or had this same problem and it is resolved, I'd appreciate knowing how and where to get information. Thanks in advance for your help and your computer happy.

    Rhamnar68It

    "A security update for SQL Server 2005 Service Pack 3 (KB970892) istall failure."

    I'm not sure if this is the right place to post this but I hope I can get help.
    I can't get the update mentioned above to install after several attempts. Have searched the knowledge base and tried various suggestions of solutions without success.
    If anyone has or had this same problem and it is resolved, I'd appreciate knowing how and where to get information. Thanks in advance for your help and your computer happy.

    Rhamnar68It

    It isn't really the right place (better would have been the forum of Windows Update ), but see the following thread: http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/cafab790-e540-40d3-87ba-4f64e6e82d54/

  • Do not install the update for SQL Server 2005 Service Pack 3 (KB970892) security code error C0000005

    Do not install the update for SQL Server 2005 Service Pack 3 (KB970892) security code error C0000005

    This update didn't install when I used Vista and is still unable to install now, I updated to Windows 7.

    Have searched for a solution for months with no result. Reason why I updated.

    Any help much appreciated.

    DOUGY,

    Microsoft SQL Server 2005 Express Edition Service Pack

    Post here for assistance:

    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/

    --

  • INSTALL update for SQL Server 2005 Service Pack 3 (KB970892) security FAILURE

    A security update for SQL Server 2005 Service Pack 3 (KB970892) WHO CAME through AUTOMATIV UPDATES will NOT INSTALL ON MY PC. Why not?!
    And the Microsoft web site is very helpful in this area. Please get this sort

    You can post on this specific forum: SQL Server Setup & Upgrade
    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/

    or if this is related:

    Error code when you use Windows Update or Microsoft Update to install updates:

    '0x737D '.

    http://support.Microsoft.com/kb/978597 [all OSS]

    TaurArian [MVP] 2005-2010 - Update Services

  • Update of SQL Server 2005 Express Edition Svc Pack 3 has no 42 9 error code

    Update for SQL Server 2005 Express Edition Svc Pack 3 {KB988706} update failed errorcode 42 9.  Anyone encountered this error code any ideas how to fix

    Visit this forum:

    SQL Installation of Server & upgrade
    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/ TaurArian [MVP] 2005-2010 - Update Services

  • Update error - SQL Server 2008 SP1

    Hello

    I am using Windows 7 Ultimate 64 bit

    I installed VS2010 Trail, then I installed SQL Server Express Studio

    My Windows shows update there is a update for SQl Server 2008 Service Pack 1

    But when I try to install this update

    I get an error like below

    Error Code 84 B 20001

    a few times with error below

    WindowsUpdate_20000001 WindowsUpdate_dt000

    What should I do to fix this

    Thank you

    Harsha

    RedandBlue,
    The link Shalini gave about the clean boot procedure provides detailed instructions on the use of MSConfig.  I think you have just misunderstood the steps listed above.  When you open msconfig, click on the button beside selective startup. Then uncheck (clear) the box "Load system services" and "Load Startup items" and then apply and restart.

    If you have not seen this thread , you can read through it, because it covers the same error you see. Mike - Engineer Support Microsoft Answers
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • S update for SQL Server 2005 service pack 3 (KB970892) does not install

    Won't install dry not updated for SQL Server 2005 service pack 3 (KB970892).

    OTHER updates WILL install. I have a software on my computer (NVivo8), which I think is related to SQL - could I have to delete this before the service pack updates?

    Try this forum:
    The SQL Server installation & set program at level
    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/ TaurArian [MVP] 2005-2010 - Update Services

  • 64C__Vista 64/security update for SQL server 2005 Service Pack 3 (KB970892) problem code

    I get a request for update update of SQL server 2005, (not even sure if I need the SQL code on my laptop) and it never ends. It errors. It seems to open a box to find a file called (sqlrun_sql.msi) this file does not exist on my system. Unable to reinstall SQL server 2005, it is impossible to uninstall.

    When I try yo install service pack manually the x 86 worm say to use the x 64, x 64 say to use the X 86 worm. ???

    If I do not need SQL server, I would really like to remove it. But how.

    Thanks for any help

    You may find the answer on this forum:

    The SQL Server installation & set program at level
    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/ TaurArian [MVP] 2005-2010 - Update Services

  • I'm Zenith one 733F error Code when I try to install Windows Vista update to SQL Server 2005 (Service Pack 2 KB970895).

    I'm Zenith one 733F error Code when I try to install the latest Windows Vista Update, which is an update to SQL Server 2005 (Service Pack 2 KB970895).  This update has failed several times now.

    I followed the advice given in a separate post in this forum at Ramer49 to perform a selective startup with msconfig to try to run the update with all Microsoft Services disabled.  This does not solve the problem.

    I spent reviewing the logfile under C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Hotfix\SQL9_Hotfix_KB970895_sqlrun_sql.msp.log.  The problem highlighted is that the Services of Services SQL2005 database program did not start.  Here is an excerpt from the log file...

    Product Installation status
    Product: SQL Server Database Services 2005 (MSSMLBIZ)
    (Previous) product version: 3077
    Version of the product (Final):
    Status: failed
    Log file: C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Hotfix\SQL9_Hotfix_KB970895_sqlrun_sql.msp.log
    SQL Express features:
    Error number: 29503
    Error description: error MSP: 29503 The SQL Server service could not start. For more information, see the

    I tried to run the problem file (SQL Server MSSMLBIZ) directly by using the Windows administrative tool, but the file does not seem to start successfully.  Event Viewer log contains an error with event ID = 823.

    I don't know what to do next.

    Can someone help me?

    Thank you.

    Take a look at this link as it covers a way to fix this problem. Mike - Engineer Support Microsoft Answers
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Two updates - for "SQL Server 2005 Service Pack 3 'and 'Power Poin 2007", throwing errors when installing Code FF Code 80070663

    Original title: two updates - for "SQL Server 2005 Service Pack 3 'and 'Power Poin 2007", throwing errors during installation

    For several months, one day each on ' Windows Vista Bussiness "and"MS Office Professional 2007' install.

    Relevant updates are:-

    1 security Update for SQL Server 2005 Service Pack 3 (KB2494113)

    2 update for Microsoft Office PowerPoint 2007 (KB2535818)

    The lifted message when the update is "patch installer has stopped working".

    Finally, the "errors:" are: -.

    Code FF  Windows Update has encountered an unknown error

    Code 80070663  Windows Update has encountered an unknown error

    I tried nmerous solutions suggested on the forums but nothing helped.

    Please suggest what you please!

    Hello

    Have what troubleshooting steps you tried?

    Answer to the above question could help us by providing the best troubleshooting steps.
    However, visit the link below to download and install the update of security for Microsoft Office PowerPoint 2007 (KB2535818) update.
    http://www.Microsoft.com/download/en/details.aspx?ID=24723

  • C 64 Vista 64/security update for SQL server 2005 Service Pack 3 (KB970892) problem code

    I get a request for update update of SQL server 2005, (not even sure if I need the SQL code on my laptop) and it never ends. It errors. It seems to open a box to find a file called (sqlrun_sql.msi) this file does not exist on my system. Unable to reinstall SQL server 2005, it is impossible to uninstall.

    When I try yo install service pack manually the x 86 worm say to use the x 64, x 64 say to use the X 86 worm. ???

    If I do not need SQL server, I would really like to remove it. But how.

    Thanks for any help

    Windows Update Forum:

    It comes with Vista, upgrade install and activate Forum.

    You will get the best help for any problem of Update/Service Pack in the Windows Update Forum; the link below:

    http://social.answers.Microsoft.com/forums/en-us/vistawu/threads

    When you repost here, kindly include the Error Codes, and exactly what is happening when you try to update.

    In this way, you will receive the best help.

    See you soon.

    Mick Murphy - Microsoft partner

  • Auto-Update for SQL Server Express Edition 2005, 2008, 2012, 2014

    An auto-update feature exist for SQL Server Express Edition? If so, is it something that is enabled by default on the package, and where you can locate the function, if you want to disable it?

    Thank you!

    Matt

    This issue is beyond the scope of this site which is for the consumer to related issues.
    To ensure that you get a proper answer, ask either on the Technet site, if it is a type of Pro problem, or MSDN if it's related to the developer
    *
  • Update Windows SQL Server 2005 Express Edition cannot install KB2463332

    I use Windows XP Professional and I'm unable to install the most recent Windows Update KB2463332 for Windows SQL Server 2005 Express Edition SP4

    I am able to download... but when it runs the installation of locks.  Microsoft has released about 7 updates recently and I was able to install all except KB2463332

    Why this update lock on installation?

    Thank you!

    Hi BarbE52,

    1. you receive messages or error codes?

    2. have you tried to install the update manually?

    Method 1:

    You can read the following article and try to reset the Windows Update components and check.

    How to reset the Windows Update components?

    http://support.Microsoft.com/kb/971058

    Method 2:

    You can try to download and install the standalone update package.

    a. download the update from the Microsoft Download Center:

    http://www.Microsoft.com/downloads/en/

    Also check out the link:

    How to obtain the latest service pack for SQL Server 2005

    http://support.Microsoft.com/kb/913089

    b. double-click on the downloaded file.

    c. you can either click Run to start the installation or you can click on save and save it on the desktop and run the installation once the update is completely downloaded.

    Hope this information is useful.

    Jeremy K
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • I get the 737D error code when you try to install the update for SQL Server 2005 Service Pack 3 (KB970892) security. Any suggestions or should I not worry about installing this?

    I use Windows XP Home Edition Version 2002 Service Pack 3.

    Here is a link to a thread on the MSDN forums dealing with this problem and a possible solution.  Thread  Also, if you run law or another program directly using SQL, you can try to uninstall the program, run the update, then reinstall the program.  If you have tried only to install this through Windows Update you can want to download it and run it directly from your desktop.

    Mike - Engineer Support Microsoft Answers
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • A security update for SQL Server 2005 Service Pack 2 (KB948109) guard installation time and again. __


    Security for the SQL Server 2005 Service Pack 2 (KB948109) update has successfully installed but the icon comes back no matter how many times I install the update.  What can I do?

    Not much info in this part of the newspaper.

    Again, it may be more appropriate post on this forum:
    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/
    as they are use to deal with these updates.

    When I mentioned the installation of the update in safe mode, I was suggesting the full file downloading and then installing in safe mode.

    http://www.Microsoft.com/downloads/en/results.aspx?FREETEXT=kb948109&displaylang=en&sType=s_basic TaurArian [MVP] 2005-2010 - Update Services

Maybe you are looking for

  • You bird 31 crashes when you reply to an e-mail from multiple threads

    I've updated to version 31 today. Since then, when replying to emails that have several threads (2 or 3 responses attached) the Send button hang up. If I wait long enough, or violin, it can go to the project. Why? What can I do to get this kind of th

  • iPods Don't not grateful, Windows 10 "dysfunction."

    Hi all, I recently bought a new laptop, imported from my old iTunes library - it all went fine so far. However, to connect my iPod Nano 3rd generation and iPod Nano 6th generation, my computer says that the software has malfunctioned and that it is u

  • After being off for ten days, MBP is going very slowly

    Hi all During the festive period, that I have done any work on computer and since then it is very slow and jerky when I opened a window, for example, get a black screen where the new window opens for a brief second. I also see the wheel that rotates

  • HP pavilion m6-1002sa internal laptop hard drive replacement

    Computer - laptop HP pavilion m6-1002sa Operating system - Windows 7 Edition home premium The drive on the computer that the above has failed and I would like to replace it with one:

  • Why my custom control consuming 30% of the CPU power?

    Hello on my laptot C2D 2.0 GHZ if I open just VI with custom control I developed it consumes about 30% of the CPU power. Could someone explain why? Is also my problem with this control? I see it with 8.5 and 8.6 as well. It must be linked to its repr