Can some tell me where I can find the list of latest updates for SQL Server
2005? I'd like to find a way of being informed when the latest update is
released (I'm assuming Microsoft Update doesn't list the cumulative update
packages released every so often?)?
Thanks - John.
No, there is no definitive place to watch. I will include a bunch of posts
I have made on new builds below. I try to stay on top of it, but I am only
human, and have other responsibilities, like day job, family, etc.
http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/12/419.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/06/service-pack-2a.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/28/an-update-on-recent-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/04/the-drama-continues-more-post-sp2-fallout.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/11/more-on-gdrs-qfes-and-the-aftermath-of-sp2.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/05/03/some-new-or-updated-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/staying-on-top-of-sql-server-2005-builds-and-hotfixes.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/some-new-and-updated-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/09/11/new-cumulative-update-is-available.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/10/16/quick-update-new-cumulative-update-has-been-released.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/06/list-of-sql-server-2005-post-sp2-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/19/i-would-rather-see-sp3-but-i-ll-take-cu6-instead.aspx
And then these guys try to keep a list too, but everyone seems to have
little holes in their lists here and there:
http://www.aspfaq.com/sql2005/show.asp?id=20
http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx
http://sqlserverbuilds.blogspot.com/
http://www.sqlservercentral.com/articles/Administration/2960/
Microsoft is trying to maintain a list, but the following one is only 3152+
http://support.microsoft.com/kb/937137/
"John Davis" <jdavis707@.hotmail.com> wrote in message
news:uTv4DiMkIHA.2276@.TK2MSFTNGP05.phx.gbl...
> Can some tell me where I can find the list of latest updates for SQL
> Server 2005? I'd like to find a way of being informed when the latest
> update is released (I'm assuming Microsoft Update doesn't list the
> cumulative update packages released every so often?)?
> Thanks - John.
|||You'd think the best place to keep track of this type of stuff would MS <sigh>.
Linchi
"Aaron Bertrand [SQL Server MVP]" wrote:
> No, there is no definitive place to watch. I will include a bunch of posts
> I have made on new builds below. I try to stay on top of it, but I am only
> human, and have other responsibilities, like day job, family, etc.
> http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/12/419.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/06/service-pack-2a.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/28/an-update-on-recent-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/04/the-drama-continues-more-post-sp2-fallout.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/11/more-on-gdrs-qfes-and-the-aftermath-of-sp2.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/05/03/some-new-or-updated-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/staying-on-top-of-sql-server-2005-builds-and-hotfixes.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/some-new-and-updated-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/09/11/new-cumulative-update-is-available.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/10/16/quick-update-new-cumulative-update-has-been-released.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/06/list-of-sql-server-2005-post-sp2-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/19/i-would-rather-see-sp3-but-i-ll-take-cu6-instead.aspx
> And then these guys try to keep a list too, but everyone seems to have
> little holes in their lists here and there:
> http://www.aspfaq.com/sql2005/show.asp?id=20
> http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx
> http://sqlserverbuilds.blogspot.com/
> http://www.sqlservercentral.com/articles/Administration/2960/
> Microsoft is trying to maintain a list, but the following one is only 3152+
> http://support.microsoft.com/kb/937137/
>
> "John Davis" <jdavis707@.hotmail.com> wrote in message
> news:uTv4DiMkIHA.2276@.TK2MSFTNGP05.phx.gbl...
>
Showing posts with label updates. Show all posts
Showing posts with label updates. Show all posts
Wednesday, March 28, 2012
Latest Updates
Can some tell me where I can find the list of latest updates for SQL Server
2005? I'd like to find a way of being informed when the latest update is
released (I'm assuming Microsoft Update doesn't list the cumulative update
packages released every so often?)?
Thanks - John.No, there is no definitive place to watch. I will include a bunch of posts
I have made on new builds below. I try to stay on top of it, but I am only
human, and have other responsibilities, like day job, family, etc.
http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/12/419.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/06/service-pack-2a.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/28/an-update-on-recent-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/04/the-drama-continues-more-post-sp2-fallout.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/11/more-on-gdrs-qfes-and-the-aftermath-of-sp2.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/05/03/some-new-or-updated-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/staying-on-top-of-sql-server-2005-builds-and-hotfixes.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/some-new-and-updated-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/09/11/new-cumulative-update-is-available.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/10/16/quick-update-new-cumulative-update-has-been-released.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/06/list-of-sql-server-2005-post-sp2-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/19/i-would-rather-see-sp3-but-i-ll-take-cu6-instead.aspx
And then these guys try to keep a list too, but everyone seems to have
little holes in their lists here and there:
http://www.aspfaq.com/sql2005/show.asp?id=20
http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx
http://sqlserverbuilds.blogspot.com/
http://www.sqlservercentral.com/articles/Administration/2960/
Microsoft is trying to maintain a list, but the following one is only 3152+
http://support.microsoft.com/kb/937137/
"John Davis" <jdavis707@.hotmail.com> wrote in message
news:uTv4DiMkIHA.2276@.TK2MSFTNGP05.phx.gbl...
> Can some tell me where I can find the list of latest updates for SQL
> Server 2005? I'd like to find a way of being informed when the latest
> update is released (I'm assuming Microsoft Update doesn't list the
> cumulative update packages released every so often?)?
> Thanks - John.|||You'd think the best place to keep track of this type of stuff would MS <sigh>.
Linchi
"Aaron Bertrand [SQL Server MVP]" wrote:
> No, there is no definitive place to watch. I will include a bunch of posts
> I have made on new builds below. I try to stay on top of it, but I am only
> human, and have other responsibilities, like day job, family, etc.
> http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/12/419.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/06/service-pack-2a.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/28/an-update-on-recent-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/04/the-drama-continues-more-post-sp2-fallout.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/11/more-on-gdrs-qfes-and-the-aftermath-of-sp2.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/05/03/some-new-or-updated-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/staying-on-top-of-sql-server-2005-builds-and-hotfixes.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/some-new-and-updated-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/09/11/new-cumulative-update-is-available.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/10/16/quick-update-new-cumulative-update-has-been-released.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/06/list-of-sql-server-2005-post-sp2-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/19/i-would-rather-see-sp3-but-i-ll-take-cu6-instead.aspx
> And then these guys try to keep a list too, but everyone seems to have
> little holes in their lists here and there:
> http://www.aspfaq.com/sql2005/show.asp?id=20
> http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx
> http://sqlserverbuilds.blogspot.com/
> http://www.sqlservercentral.com/articles/Administration/2960/
> Microsoft is trying to maintain a list, but the following one is only 3152+
> http://support.microsoft.com/kb/937137/
>
> "John Davis" <jdavis707@.hotmail.com> wrote in message
> news:uTv4DiMkIHA.2276@.TK2MSFTNGP05.phx.gbl...
> > Can some tell me where I can find the list of latest updates for SQL
> > Server 2005? I'd like to find a way of being informed when the latest
> > update is released (I'm assuming Microsoft Update doesn't list the
> > cumulative update packages released every so often?)?
> >
> > Thanks - John.
>
2005? I'd like to find a way of being informed when the latest update is
released (I'm assuming Microsoft Update doesn't list the cumulative update
packages released every so often?)?
Thanks - John.No, there is no definitive place to watch. I will include a bunch of posts
I have made on new builds below. I try to stay on top of it, but I am only
human, and have other responsibilities, like day job, family, etc.
http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/12/419.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/06/service-pack-2a.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/28/an-update-on-recent-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/04/the-drama-continues-more-post-sp2-fallout.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/11/more-on-gdrs-qfes-and-the-aftermath-of-sp2.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/05/03/some-new-or-updated-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/staying-on-top-of-sql-server-2005-builds-and-hotfixes.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/some-new-and-updated-sql-server-2005-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/09/11/new-cumulative-update-is-available.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2007/10/16/quick-update-new-cumulative-update-has-been-released.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/06/list-of-sql-server-2005-post-sp2-builds.aspx
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/19/i-would-rather-see-sp3-but-i-ll-take-cu6-instead.aspx
And then these guys try to keep a list too, but everyone seems to have
little holes in their lists here and there:
http://www.aspfaq.com/sql2005/show.asp?id=20
http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx
http://sqlserverbuilds.blogspot.com/
http://www.sqlservercentral.com/articles/Administration/2960/
Microsoft is trying to maintain a list, but the following one is only 3152+
http://support.microsoft.com/kb/937137/
"John Davis" <jdavis707@.hotmail.com> wrote in message
news:uTv4DiMkIHA.2276@.TK2MSFTNGP05.phx.gbl...
> Can some tell me where I can find the list of latest updates for SQL
> Server 2005? I'd like to find a way of being informed when the latest
> update is released (I'm assuming Microsoft Update doesn't list the
> cumulative update packages released every so often?)?
> Thanks - John.|||You'd think the best place to keep track of this type of stuff would MS <sigh>.
Linchi
"Aaron Bertrand [SQL Server MVP]" wrote:
> No, there is no definitive place to watch. I will include a bunch of posts
> I have made on new builds below. I try to stay on top of it, but I am only
> human, and have other responsibilities, like day job, family, etc.
> http://sqlblog.com/blogs/aaron_bertrand/archive/2006/12/12/419.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/06/service-pack-2a.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/03/28/an-update-on-recent-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/04/the-drama-continues-more-post-sp2-fallout.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/04/11/more-on-gdrs-qfes-and-the-aftermath-of-sp2.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/05/03/some-new-or-updated-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/staying-on-top-of-sql-server-2005-builds-and-hotfixes.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/06/27/some-new-and-updated-sql-server-2005-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/09/11/new-cumulative-update-is-available.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2007/10/16/quick-update-new-cumulative-update-has-been-released.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/06/list-of-sql-server-2005-post-sp2-builds.aspx
> http://sqlblog.com/blogs/aaron_bertrand/archive/2008/02/19/i-would-rather-see-sp3-but-i-ll-take-cu6-instead.aspx
> And then these guys try to keep a list too, but everyone seems to have
> little holes in their lists here and there:
> http://www.aspfaq.com/sql2005/show.asp?id=20
> http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx
> http://sqlserverbuilds.blogspot.com/
> http://www.sqlservercentral.com/articles/Administration/2960/
> Microsoft is trying to maintain a list, but the following one is only 3152+
> http://support.microsoft.com/kb/937137/
>
> "John Davis" <jdavis707@.hotmail.com> wrote in message
> news:uTv4DiMkIHA.2276@.TK2MSFTNGP05.phx.gbl...
> > Can some tell me where I can find the list of latest updates for SQL
> > Server 2005? I'd like to find a way of being informed when the latest
> > update is released (I'm assuming Microsoft Update doesn't list the
> > cumulative update packages released every so often?)?
> >
> > Thanks - John.
>
Friday, March 23, 2012
lastmodified
Hi,
Can someone provide me a simple trigger where it updates a lastmodified
column.
It should update the column lastmodified whenever an update occurs on all
the other columns.
ThnxCREATE TRIGGER tr_YourTrigger
ON YourTable
FOR UPDATE
AS
IF @.@.ROWCOUNT > 0
UPDATE YourTable SET [LastModified] = GETDATE()
WHERE YourPK IN (SELECT b.PK FROM Inserted AS b)
Andrew J. Kelly SQL MVP
"Jason" <jlewis@.hotmail.com> wrote in message
news:O$XaerRGFHA.2568@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Can someone provide me a simple trigger where it updates a lastmodified
> column.
> It should update the column lastmodified whenever an update occurs on all
> the other columns.
> Thnx
>|||In addition to Andrew's response you can use DEFAULT constraint
CREATE TABLE #Test
(
col DATETIME DEFAULT GETDATE()
)
INSERT INTO #Test DEFAULT VALUES
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:eV5joCSGFHA.2976@.TK2MSFTNGP09.phx.gbl...
> CREATE TRIGGER tr_YourTrigger
> ON YourTable
> FOR UPDATE
> AS
>
> IF @.@.ROWCOUNT > 0
> UPDATE YourTable SET [LastModified] = GETDATE()
> WHERE YourPK IN (SELECT b.PK FROM Inserted AS b)
>
> --
> Andrew J. Kelly SQL MVP
>
> "Jason" <jlewis@.hotmail.com> wrote in message
> news:O$XaerRGFHA.2568@.TK2MSFTNGP10.phx.gbl...
all[vbcol=seagreen]
>|||That only works for Inserts. He specifically asked for Updates.
Andrew J. Kelly SQL MVP
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uuRRBDYGFHA.2156@.TK2MSFTNGP09.phx.gbl...
> In addition to Andrew's response you can use DEFAULT constraint
> CREATE TABLE #Test
> (
> col DATETIME DEFAULT GETDATE()
> )
> INSERT INTO #Test DEFAULT VALUES
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:eV5joCSGFHA.2976@.TK2MSFTNGP09.phx.gbl...
> all
>|||Thanks, my mistake.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:esONVXbGFHA.560@.TK2MSFTNGP15.phx.gbl...
> That only works for Inserts. He specifically asked for Updates.
> --
> Andrew J. Kelly SQL MVP
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:uuRRBDYGFHA.2156@.TK2MSFTNGP09.phx.gbl...
lastmodified[vbcol=seagreen]
>
Can someone provide me a simple trigger where it updates a lastmodified
column.
It should update the column lastmodified whenever an update occurs on all
the other columns.
ThnxCREATE TRIGGER tr_YourTrigger
ON YourTable
FOR UPDATE
AS
IF @.@.ROWCOUNT > 0
UPDATE YourTable SET [LastModified] = GETDATE()
WHERE YourPK IN (SELECT b.PK FROM Inserted AS b)
Andrew J. Kelly SQL MVP
"Jason" <jlewis@.hotmail.com> wrote in message
news:O$XaerRGFHA.2568@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Can someone provide me a simple trigger where it updates a lastmodified
> column.
> It should update the column lastmodified whenever an update occurs on all
> the other columns.
> Thnx
>|||In addition to Andrew's response you can use DEFAULT constraint
CREATE TABLE #Test
(
col DATETIME DEFAULT GETDATE()
)
INSERT INTO #Test DEFAULT VALUES
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:eV5joCSGFHA.2976@.TK2MSFTNGP09.phx.gbl...
> CREATE TRIGGER tr_YourTrigger
> ON YourTable
> FOR UPDATE
> AS
>
> IF @.@.ROWCOUNT > 0
> UPDATE YourTable SET [LastModified] = GETDATE()
> WHERE YourPK IN (SELECT b.PK FROM Inserted AS b)
>
> --
> Andrew J. Kelly SQL MVP
>
> "Jason" <jlewis@.hotmail.com> wrote in message
> news:O$XaerRGFHA.2568@.TK2MSFTNGP10.phx.gbl...
all[vbcol=seagreen]
>|||That only works for Inserts. He specifically asked for Updates.
Andrew J. Kelly SQL MVP
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uuRRBDYGFHA.2156@.TK2MSFTNGP09.phx.gbl...
> In addition to Andrew's response you can use DEFAULT constraint
> CREATE TABLE #Test
> (
> col DATETIME DEFAULT GETDATE()
> )
> INSERT INTO #Test DEFAULT VALUES
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:eV5joCSGFHA.2976@.TK2MSFTNGP09.phx.gbl...
> all
>|||Thanks, my mistake.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:esONVXbGFHA.560@.TK2MSFTNGP15.phx.gbl...
> That only works for Inserts. He specifically asked for Updates.
> --
> Andrew J. Kelly SQL MVP
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:uuRRBDYGFHA.2156@.TK2MSFTNGP09.phx.gbl...
lastmodified[vbcol=seagreen]
>
Friday, March 9, 2012
Large updates and locks
Hi there,
I am looking over some code in a project I just joined and found
something that I am not sure about. The are processes which update or
delete many rows of data and the approach chosen to perform these
updates and deletes was through cursors. The setup looks something
like this:
Example:
DECLARE Orders CURSOR FOR select order_id from order where order_Date +
10 < getdate();
loop
begin
fetch orders into @.OrderId;
delete orderdetail where order_id = @.OrderId;
end;
Instead of:
delete orderdetail from orderdetail join orders where orders.order_date
+ 10 < getdate();
The motivation for it is that the locks will be more granular and other
processes will be able to access the tables instead of being locked out
for the duration of the process. The cursor approach is obviously
slower by few orders of magnitude to execute but that aside does this
approach make sense?
ThanksThis might make sense in some cases. Batching data modifications is a
common method of getting around locking issues. But whether it's necessary
or not is difficult to know based on the information you've given so far.
What percentage of the rows are being deleted each time? Is there an index
to support the deletion? Currently, your predicate (order_date + 10 <
getdate()) cannot use indexes, so the answer to the latter question is no.
You may have better luck with:
DELETE FROM orderdetail
WHERE EXISTS
(
SELECT *
FROM orders
WHERE orders.order_id = orderdetail.order_id
AND orders.order_date <= GETDATE() - 10
)
This will be able to take advantage of an index on the order_date column,
and therefore may perform better (and take more granular locks) than a
non-cursor approach using (order_date + 10).
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"boblotz2001" <boblotz2001@.yahoo.com> wrote in message
news:1124715871.853196.33820@.g44g2000cwa.googlegroups.com...
> Hi there,
> I am looking over some code in a project I just joined and found
> something that I am not sure about. The are processes which update or
> delete many rows of data and the approach chosen to perform these
> updates and deletes was through cursors. The setup looks something
> like this:
> Example:
> DECLARE Orders CURSOR FOR select order_id from order where order_Date +
> 10 < getdate();
> loop
> begin
> fetch orders into @.OrderId;
> delete orderdetail where order_id = @.OrderId;
> end;
> Instead of:
> delete orderdetail from orderdetail join orders where orders.order_date
> + 10 < getdate();
> The motivation for it is that the locks will be more granular and other
> processes will be able to access the tables instead of being locked out
> for the duration of the process. The cursor approach is obviously
> slower by few orders of magnitude to execute but that aside does this
> approach make sense?
> Thanks
>
I am looking over some code in a project I just joined and found
something that I am not sure about. The are processes which update or
delete many rows of data and the approach chosen to perform these
updates and deletes was through cursors. The setup looks something
like this:
Example:
DECLARE Orders CURSOR FOR select order_id from order where order_Date +
10 < getdate();
loop
begin
fetch orders into @.OrderId;
delete orderdetail where order_id = @.OrderId;
end;
Instead of:
delete orderdetail from orderdetail join orders where orders.order_date
+ 10 < getdate();
The motivation for it is that the locks will be more granular and other
processes will be able to access the tables instead of being locked out
for the duration of the process. The cursor approach is obviously
slower by few orders of magnitude to execute but that aside does this
approach make sense?
ThanksThis might make sense in some cases. Batching data modifications is a
common method of getting around locking issues. But whether it's necessary
or not is difficult to know based on the information you've given so far.
What percentage of the rows are being deleted each time? Is there an index
to support the deletion? Currently, your predicate (order_date + 10 <
getdate()) cannot use indexes, so the answer to the latter question is no.
You may have better luck with:
DELETE FROM orderdetail
WHERE EXISTS
(
SELECT *
FROM orders
WHERE orders.order_id = orderdetail.order_id
AND orders.order_date <= GETDATE() - 10
)
This will be able to take advantage of an index on the order_date column,
and therefore may perform better (and take more granular locks) than a
non-cursor approach using (order_date + 10).
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"boblotz2001" <boblotz2001@.yahoo.com> wrote in message
news:1124715871.853196.33820@.g44g2000cwa.googlegroups.com...
> Hi there,
> I am looking over some code in a project I just joined and found
> something that I am not sure about. The are processes which update or
> delete many rows of data and the approach chosen to perform these
> updates and deletes was through cursors. The setup looks something
> like this:
> Example:
> DECLARE Orders CURSOR FOR select order_id from order where order_Date +
> 10 < getdate();
> loop
> begin
> fetch orders into @.OrderId;
> delete orderdetail where order_id = @.OrderId;
> end;
> Instead of:
> delete orderdetail from orderdetail join orders where orders.order_date
> + 10 < getdate();
> The motivation for it is that the locks will be more granular and other
> processes will be able to access the tables instead of being locked out
> for the duration of the process. The cursor approach is obviously
> slower by few orders of magnitude to execute but that aside does this
> approach make sense?
> Thanks
>
Subscribe to:
Posts (Atom)