Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Tuesday, March 27, 2012

Failed to install: Cumulative hotfix package (build 2153) for SQL Server 2005 (KB918222)

Hi experts!

I try to update SQL Server 2005 SP1 with the Cumulative hotfix package (build 2153). I need to do this, because I get an error this hotfix is said to fix... and of course - the update completely crashes (sending an error report to microsoft).

Here is what the log looks like:

Failed ACL:
SetSecurityFileDescriptor is failed at the error code 5; Converted SDDL: '(A;OICI;FA;;;S-1-5-21-1276437202-3579633377-1796755180-1012)'
Error Code: 0x80077342 (29506)
Windows Error Text: Source File Name: sqlca\sqlsddlca.cpp
Compiler Timestamp: Tue Apr 11 11:45:24 2006
Function Name: ExceptionInSDDL
Source Line Number: 65

- Context --


Setting status of unmanaged components and removing unmanaged resources

MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
Error Code: 29506
MSI (s) (50!B4) [23:18:29:854]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:854]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:870]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:870]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:870]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:870]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:870]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:870]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:870]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:870]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:870]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:870]: Transforming table Error.

MSI (s) (50!B4) [23:18:29:870]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (50!B4) [23:18:29:870]: Product: Microsoft SQL Server 2005 -- Error 29506. SQL Server Setup failed to modify security permissions on file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ for user SQL. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that exists on the destination drive.

Error 29506. SQL Server Setup failed to modify security permissions on file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ for user SQL. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that exists on the destination drive.
<Failure Type='Fatal' Error='29506'>
<EndFunc Name='LaunchFunction' Return='29506' GetLastError='0'>
MSI (s) (50:34) [23:18:29:886]: User policy value 'DisableRollback' is 0
MSI (s) (50:34) [23:18:29:886]: Machine policy value 'DisableRollback' is 0
Action ended 23:18:29: InstallFinalize. Return value 3.
MSI (s) (50:34) [23:18:29:964]: Executing op: Header(Signature=1397708873,Version=301,Timestamp=910146116,LangId=1033,Platform=0,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)
MSI (s) (50:34) [23:18:29:964]: Executing op: DialogInfo(Type=0,Argument=1033)
MSI (s) (50:34) [23:18:29:964]: Executing op: DialogInfo(Type=1,Argument=Microsoft SQL Server 2005)
MSI (s) (50:34) [23:18:29:964]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1])
MSI (s) (50:34) [23:18:29:964]: Executing op: RegisterBackupFile(File=C:\Config.Msi\643b07e2.rbf)
MSI (s) (50:34) [23:18:29:964]: Executing op: RegisterBackupFile(File=C:\Config.Msi\643b07e3.rbf)
MSI (s) (50:34) [23:18:29:979]: Executing op: RegisterBackupFile(File=C:\Config.Msi\643b07e4.rbf)
MSI (s) (50:34) [23:18:29:979]: Executing op: RegisterBackupFile(File=C:\Config.Msi\643b07e5.rbf)
MSI (s) (50:34) [23:18:29:979]: Executing op: RegisterBackupFile(File=C:\Config.Msi\643b07e6.rbf)
MSI (s) (50:34) [23:18:29:979]: Executing op: ActionStart(Name=Do_sqlFileSDDL.D20239D7_E87C_40C9_9837_E70B8D4882C2,Description=Setting File Security,Template=File: [1])
MSI (s) (50:34) [23:18:29:979]: Executing op: ProductInfo(ProductKey={130A3BE1-85CC-4135-8EA7-5A724EE6CE2C},ProductName=Microsoft SQL Server 2005,PackageName=SqlRun_SQL.msi,Language=1033,Version=151062527,Assignment=1,ObsoleteArg=0,ProductIcon=ARPIcon.ico,PackageMediaPath=\Setup\,PackageCode={3185FC73-41E0-43F4-97DF-2254C4D7C667},,,InstanceType=0,LUASetting=0,RemoteURTInstalls=0)
MSI (s) (50:34) [23:18:29:979]: Executing op: ActionStart(Name=Do_sqlUserSecurity.D20239D7_E87C_40C9_9837_E70B8D4882C2,Description=Setting User Security,Template=Account: [1])
MSI (s) (50:34) [23:18:29:979]: Executing op: ActionStart(Name=Do_sqlGroupMember.D20239D7_E87C_40C9_9837_E70B8D4882C2,Description=Installing Local Groups,)
MSI (s) (50:34) [23:18:29:979]: Executing op: ActionStart(Name=Rollback_sqlGroupMember.D20239D7_E87C_40C9_9837_E70B8D4882C2,Description=Installing Local Groups,)
MSI (s) (50:34) [23:18:29:979]: Executing op: CustomActionRollback(Action=Rollback_sqlGroupMember.D20239D7_E87C_40C9_9837_E70B8D4882C2,ActionType=1345,Source=BinaryData,Target=Rollback_sqlGroupMember,CustomActionData=1 0 0 Installing Local Groups 50000 SQLServer2005MSFTEUser$KMAUSQL01SRV$MSSQLSERVER NT AUTHORITY\LocalService )
MSI (s) (50:68) [23:18:29:995]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSICD9.tmp, Entrypoint: Rollback_sqlGroupMember
<Func Name='LaunchFunction'>

I would really be thankful for any hint regarding what to do to solve this problem.... As said - I have an error occuring, this hotfix is said to fix - to be exact, it's the one stating "not to be able to build the execution plan under some circumstances when using a SQL query inside a stored procedure"

Help greatly appreciated!!

Greetings, Wolfgang

Make sure the acct used to startup sqlserver service has read/write access to the folder listed. Also, be sure you login as admin to run setup.

|||

Thanks for your reply oj!

Actually I was logged in as member of the 'Administrators' group... That's what bugged me so much... But as I followed your hint and tried to modify the permissions of the folder manually I immediately got a Windows-Authentication Modal Popup - telling me that I have to authenticate to the domain...

So the problem was that I was local administrator but the hotfix-installation in fact needed mit to be also domain-administrator (don't really understand why though).

I just contacted the Domain-Admin and made him install the hotfix ;-) It worked... Thanks for the hint!

Regards,
Wolfgang

Wednesday, March 21, 2012

Failed Second updat in dbo.aspnet_Membership?

hello,

I would to update the email indbo.aspnet_Membership and[dbo].[WebMaster].

I write a stored procedure that contain 2 update one for[dbo].[WebMaster] and another for dbo.aspnet_Membership

the update in WebMaster table succes but in the dbo.aspnet_Membersh failed.

No synatxe error in stored procedure.

Can any one help me ?

Amer Azzaz

Did you get any error? Can you post your script to create the stored procedure ?

Monday, March 19, 2012

Failed Job Message

This is a post
I am in desparate need of some help with SQL Server 2000. I recently created several jobs to run at night to update several tables in my SQL Server. I then realized that I could schedule one job with various steps, so I tried to delete the original jobs
with the stored proc. but could not seem to get it to work. While examining the sysjob table in the msdn database I deleted one of the old jobs. This is where the problem started. I have since deleted the job steps out of the sysjobsteps and the sysjo
bschedule as well as systaskids for that same job. I am still getting the error notification each morning that the job failed Unable to retrieve steps for the certain job. Where is this notification coming from? Because there is no jobs or job steps in
any of the tables. Any help would greatly be appreciated.
There is a bit more that goes on in deleting a job than just
deleting rows from these tables. Jobs can be stored in the
job cache so there are also procedures that check the job
cache and update it if necessary - I think it's through
sp_agent_notify if I remember correctly. There could also be
some other references to the jobs in some of the other job
tables. That's why modifying these tables directly isn't
recommended. You could try restarting SQL Agent if you
didn't do so after modifying the tables but I'd guess you
could still have some other dangling references to the job
which may or may not affect things.
You may want to consider restoring your msdb database from
prior to your modifying the job tables and then delete the
jobs using sp_delete_job which is the supported method of
dropping a job. Using sp_delete_job will handle all the
details, update the job cache if necessary, etc.
-Sue
On Tue, 20 Apr 2004 10:51:04 -0700, "Cartman"
<anonymous@.discussions.microsoft.com> wrote:

>This is a post
>I am in desparate need of some help with SQL Server 2000. I recently created several jobs to run at night to update several tables in my SQL Server. I then realized that I could schedule one job with various steps, so I tried to delete the original job
s with the stored proc. but could not seem to get it to work. While examining the sysjob table in the msdn database I deleted one of the old jobs. This is where the problem started. I have since deleted the job steps out of the sysjobsteps and the sysj
obschedule as well as systaskids for that same job. I am still getting the error notification each morning that the job failed Unable to retrieve steps for the certain job. Where is this notification coming from? Because there is no jobs or job steps i
n any of the tables. Any help would greatly be appreciated.

Failed Job Message

This is a post
I am in desparate need of some help with SQL Server 2000. I recently created several jobs to run at night to update several tables in my SQL Server. I then realized that I could schedule one job with various steps, so I tried to delete the original jobs with the stored proc. but could not seem to get it to work. While examining the sysjob table in the msdn database I deleted one of the old jobs. This is where the problem started. I have since deleted the job steps out of the sysjobsteps and the sysjobschedule as well as systaskids for that same job. I am still getting the error notification each morning that the job failed Unable to retrieve steps for the certain job. Where is this notification coming from? Because there is no jobs or job steps in any of the tables. Any help would greatly be appreciatedThere is a bit more that goes on in deleting a job than just
deleting rows from these tables. Jobs can be stored in the
job cache so there are also procedures that check the job
cache and update it if necessary - I think it's through
sp_agent_notify if I remember correctly. There could also be
some other references to the jobs in some of the other job
tables. That's why modifying these tables directly isn't
recommended. You could try restarting SQL Agent if you
didn't do so after modifying the tables but I'd guess you
could still have some other dangling references to the job
which may or may not affect things.
You may want to consider restoring your msdb database from
prior to your modifying the job tables and then delete the
jobs using sp_delete_job which is the supported method of
dropping a job. Using sp_delete_job will handle all the
details, update the job cache if necessary, etc.
-Sue
On Tue, 20 Apr 2004 10:51:04 -0700, "Cartman"
<anonymous@.discussions.microsoft.com> wrote:
>This is a post
>I am in desparate need of some help with SQL Server 2000. I recently created several jobs to run at night to update several tables in my SQL Server. I then realized that I could schedule one job with various steps, so I tried to delete the original jobs with the stored proc. but could not seem to get it to work. While examining the sysjob table in the msdn database I deleted one of the old jobs. This is where the problem started. I have since deleted the job steps out of the sysjobsteps and the sysjobschedule as well as systaskids for that same job. I am still getting the error notification each morning that the job failed Unable to retrieve steps for the certain job. Where is this notification coming from? Because there is no jobs or job steps in any of the tables. Any help would greatly be appreciated.

Failed Job Message

This is a post
I am in desparate need of some help with SQL Server 2000. I recently create
d several jobs to run at night to update several tables in my SQL Server. I
then realized that I could schedule one job with various steps, so I tried
to delete the original jobs
with the stored proc. but could not seem to get it to work. While examining
the sysjob table in the msdn database I deleted one of the old jobs. This
is where the problem started. I have since deleted the job steps out of the
sysjobsteps and the sysjo
bschedule as well as systaskids for that same job. I am still getting the e
rror notification each morning that the job failed Unable to retrieve steps
for the certain job. Where is this notification coming from? Because there
is no jobs or job steps in
any of the tables. Any help would greatly be appreciated.There is a bit more that goes on in deleting a job than just
deleting rows from these tables. Jobs can be stored in the
job cache so there are also procedures that check the job
cache and update it if necessary - I think it's through
sp_agent_notify if I remember correctly. There could also be
some other references to the jobs in some of the other job
tables. That's why modifying these tables directly isn't
recommended. You could try restarting SQL Agent if you
didn't do so after modifying the tables but I'd guess you
could still have some other dangling references to the job
which may or may not affect things.
You may want to consider restoring your msdb database from
prior to your modifying the job tables and then delete the
jobs using sp_delete_job which is the supported method of
dropping a job. Using sp_delete_job will handle all the
details, update the job cache if necessary, etc.
-Sue
On Tue, 20 Apr 2004 10:51:04 -0700, "Cartman"
<anonymous@.discussions.microsoft.com> wrote:

>This is a post
>I am in desparate need of some help with SQL Server 2000. I recently created sever
al jobs to run at night to update several tables in my SQL Server. I then realized
that I could schedule one job with various steps, so I tried to delete the original
job
s with the stored proc. but could not seem to get it to work. While examini
ng the sysjob table in the msdn database I deleted one of the old jobs. Thi
s is where the problem started. I have since deleted the job steps out of t
he sysjobsteps and the sysj
obschedule as well as systaskids for that same job. I am still getting the
error notification each morning that the job failed Unable to retrieve steps
for the certain job. Where is this notification coming from? Because ther
e is no jobs or job steps i
n any of the tables. Any help would greatly be appreciated.

Friday, March 9, 2012

Fail to call child package

Have a parent package that calls many child packages (over 30) for a daily data warehouse update. On any given day, it randomly fails to call a child package with the following error:

Error 0x800706BE while preparing to load the package. The remote procedure call failed.

Its not failing the same package each day. I need a better explanation of this error message.

Environment: SQL2005 Enterprise Dec2005 RTM on Itanium64 with Windows DataCenter.

Are all the Execute Package tasks in the parent package configured identically? Where are the child packages stored?|||Yes, all Exec Package tasks are set up the same. All packages are stored in MSDB on our DataWarehouse server. Because we have such a large volume of packages (200), we are using folders to separate the packages. The parent package calls children in the Dimensions and various other folders. The call failures span many of the children folders, so there doesn't seem to be a pattern.

Wednesday, March 7, 2012

Facing some problem in Instead of Trigger for MultiRow Insert

This is the Trigger which is not working properly during Update, no any
record is going to be updated so pls help.

I am updating the requisition table when any update in quantity in
podetails table

CREATE TRIGGER trig_updateRequistion ON ERP.DBO.TranPurchaseOrderDetail

INSTEAD OF UPDATE

AS

IF UPDATE(Quantity)

BEGIN

Update RequisitionSlipDetail
set RequisitionSlipDetail.PoQuantity =

(Select PoQuantity from RequisitionSlipDetail where
ItemCode=(Select CAST(i.ItemCode as nvarchar(20)) from inserted as i)
and
RSlip_No=(Select CAST(i.RSlip_No as int) from inserted as i)
)
-

((Select Quantity from TranPurchaseOrderDetail where Purchase_OrderNo
=
(Select CAST(i.Purchase_OrderNo as nvarchar(20)) from inserted as i))

- (Select CAST(i.Quantity as int) from inserted as i))

where RequisitionSlipDetail.ItemCode = (Select CAST(i.ItemCode as
nvarchar(20)) from inserted as i) and RequisitionSlipDetail.RSlip_No =
(Select CAST(i.RSlip_No as int) from inserted as i)

Update TranPurchaseOrderDetail set
TranPurchaseOrderDetail.Quantity =
(Select CAST(i.Quantity as int) from inserted as i)
where TranPurchaseOrderDetail.Purchase_OrderNo = (Select
CAST(i.Purchase_OrderNo as nvarchar(20)) from inserted as i)
and
TranPurchaseOrderDetail.ItemCode = (Select CAST(i.ItemCode as
nvarchar(20)) from inserted as i)
and
TranPurchaseOrderDetail.PurchaseDetailId =
(Select PurchaseDetailId from TranPurchaseOrderDetail where
Purchase_OrderNo = (Select CAST(i.Purchase_OrderNo as nvarchar(20))
from inserted as i))

ENDsantoshborfalkar (santosh.borfalkar@.gmail.com) writes:

Quote:

Originally Posted by

This is the Trigger which is not working properly during Update, no any
record is going to be updated so pls help.
>
I am updating the requisition table when any update in quantity in
podetails table


It's very difficult to tell what might be wrong without any knowledge of
your tables or the business rules.

But I noted a few things that appears ood.

Quote:

Originally Posted by

CREATE TRIGGER trig_updateRequistion ON ERP.DBO.TranPurchaseOrderDetail
INSTEAD OF UPDATE
AS
IF UPDATE(Quantity)


So if the Quantity columns is not mentioned in the SET clause, then you
will not perform any update at all?

Quote:

Originally Posted by

Update RequisitionSlipDetail
set RequisitionSlipDetail.PoQuantity =
>
(Select PoQuantity from RequisitionSlipDetail where
ItemCode=(Select CAST(i.ItemCode as nvarchar(20)) from inserted as i)


This may work, if only one row at a time is updated, but it will fail
with an error if many rows are updated. Recall that triggers fire once
per statement, not once per row.

Quote:

Originally Posted by

Update TranPurchaseOrderDetail set
TranPurchaseOrderDetail.Quantity =
(Select CAST(i.Quantity as int) from inserted as i)
where TranPurchaseOrderDetail.Purchase_OrderNo = (Select
CAST(i.Purchase_OrderNo as nvarchar(20)) from inserted as i)
and
TranPurchaseOrderDetail.ItemCode = (Select CAST(i.ItemCode
as
nvarchar(20)) from inserted as i)
and
TranPurchaseOrderDetail.PurchaseDetailId =
(Select PurchaseDetailId from TranPurchaseOrderDetail where
Purchase_OrderNo = (Select CAST(i.Purchase_OrderNo as nvarchar(20))
from inserted as i))


I don't understand this casting business. Why cast the columns of "inserted"
when they are the same as in the target table? A simplified version of
the above could be:

Update TranPurchaseOrderDetail
set Quantity = i.Quantity
FROM TranPurchaseOrderDetail T
JOIN inserted i ON T.Purchase_OrderNo = i.Purchase_OrderNo
AND T.ItemCode = i.ItemCode
and T.PurchaseDetailId =

Quote:

Originally Posted by

(Select PurchaseDetailId from TranPurchaseOrderDetail where
Purchase_OrderNo = (Select CAST(i.Purchase_OrderNo as nvarchar(20))
from inserted as i))


I did not rewrite the last bit, because, frankly, I don't understand what
it's supposed to mean. It just looks strange.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Sunday, February 26, 2012

Extremely Slow Trigger Problem

I have an after update trigger that is killing me and I can't figure out why
.
When I run an update query that fires the trigger and look at the execution
plan, 85% of the cost is in the OPEN __0005 statement. I'm only updating 1
row, so this makes no sense to me. The I/O cost of opening the cursor is in
the 1100 range. Anyone got any ideas - I'm fresh out.
CREATE TRIGGER trgUpdate ON ITEMTASKS
FOR UPDATE
AS
DECLARE
@.ITE_ID INT,
@.TAS_ID INT,
@.STATUS TINYINT,
@.OLDSTATUS TINYINT
IF (@.@.ROWCOUNT = 0) RETURN
IF ( UPDATE( ITS_STATUS) ) BEGIN
SET NOCOUNT ON
DECLARE __0005 CURSOR LOCAL FAST_FORWARD FOR
SELECT I.ITE_ID, I.ITS_STATUS, I.TAS_ID, D.ITS_STATUS
FROM INSERTED I, DELETED D
WHERE I.ITE_ID=D.ITE_ID AND I.TAS_ID = D.TAS_ID
OPEN __0005
FETCH NEXT FROM __0005
INTO @.ITE_ID, @.STATUS, @.TAS_ID, @.OLDSTATUS
WHILE (@.@.FETCH_STATUS = 0 ) BEGIN
IF (@.STATUS = 6 ) BEGIN
UPDATE ITEMS
SET ITE_STATUS = 6
WHERE ITE_ID = @.ITE_ID
END
ELSE IF (@.STATUS = 2) AND ((SELECT TAS_ISLAST FROM TASKS WHERE TAS_ID =
@.TAS_ID)=1) BEGIN
UPDATE ITEMS
SET ITE_STATUS = 2
WHERE ITE_ID = @.ITE_ID
END
ELSE BEGIN
UPDATE ITEMS
SET ITE_STATUS = 1
WHERE ITE_ID = @.ITE_ID
END
EXEC ADD2SUMMARY_ @.ITE_ID, @.TAS_ID, @.STATUS, @.OLDSTATUS
FETCH NEXT FROM __0005
INTO @.ITE_ID, @.STATUS, @.TAS_ID, @.OLDSTATUS
END
CLOSE __0005
DEALLOCATE __0005
SET NOCOUNT OFF
ENDI strongly recommend you don't use cursors at all in triggers. Why
can't you re-write this and the contents of Add2Summary as set-based
SQL?
If you need more help then please come back with DDL, sample data
INSERT statements and show your required end result.
David Portas
SQL Server MVP
--|||Supposing that the cursor is necesary, I have two suggestions:
First -
Declare de cursor static and read_only
Second - Use EXIST in the following statement
-- ELSE IF (@.STATUS = 2) AND ((SELECT TAS_ISLAST FROM TASKS WHERE TAS_ID =
@.TAS_ID)=1) BEGIN
ELSE IF (@.STATUS = 2) AND exists(SELECT * FROM TASKS WHERE TAS_ID =
@.TAS_ID and TAS_ISLAST = 1) BEGIN
I do not know anything about the sp being executed, but the three updates
statements can be implemented without the use of the cursor.
AMB
"Arghknork" wrote:

> I have an after update trigger that is killing me and I can't figure out w
hy.
> When I run an update query that fires the trigger and look at the executi
on
> plan, 85% of the cost is in the OPEN __0005 statement. I'm only updating
1
> row, so this makes no sense to me. The I/O cost of opening the cursor is
in
> the 1100 range. Anyone got any ideas - I'm fresh out.
> CREATE TRIGGER trgUpdate ON ITEMTASKS
> FOR UPDATE
> AS
> DECLARE
> @.ITE_ID INT,
> @.TAS_ID INT,
> @.STATUS TINYINT,
> @.OLDSTATUS TINYINT
>
> IF (@.@.ROWCOUNT = 0) RETURN
> IF ( UPDATE( ITS_STATUS) ) BEGIN
> SET NOCOUNT ON
> DECLARE __0005 CURSOR LOCAL FAST_FORWARD FOR
> SELECT I.ITE_ID, I.ITS_STATUS, I.TAS_ID, D.ITS_STATUS
> FROM INSERTED I, DELETED D
> WHERE I.ITE_ID=D.ITE_ID AND I.TAS_ID = D.TAS_ID
> OPEN __0005
> FETCH NEXT FROM __0005
> INTO @.ITE_ID, @.STATUS, @.TAS_ID, @.OLDSTATUS
> WHILE (@.@.FETCH_STATUS = 0 ) BEGIN
> IF (@.STATUS = 6 ) BEGIN
> UPDATE ITEMS
> SET ITE_STATUS = 6
> WHERE ITE_ID = @.ITE_ID
> END
> ELSE IF (@.STATUS = 2) AND ((SELECT TAS_ISLAST FROM TASKS WHERE TAS_ID =
> @.TAS_ID)=1) BEGIN
> UPDATE ITEMS
> SET ITE_STATUS = 2
> WHERE ITE_ID = @.ITE_ID
> END
> ELSE BEGIN
> UPDATE ITEMS
> SET ITE_STATUS = 1
> WHERE ITE_ID = @.ITE_ID
> END
> EXEC ADD2SUMMARY_ @.ITE_ID, @.TAS_ID, @.STATUS, @.OLDSTATUS
> FETCH NEXT FROM __0005
> INTO @.ITE_ID, @.STATUS, @.TAS_ID, @.OLDSTATUS
> END
> CLOSE __0005
> DEALLOCATE __0005
> SET NOCOUNT OFF
> END
>|||Agreed, but I inherited the code and it's in production this way. It has
been working okay up until about a w ago, and I think there is an
underlying problem here I'm not seeing. Even with a cursor, it shouldn't
cost so much to open that cursor with 1 row in the inserted/deleted tables.
"David Portas" wrote:

> I strongly recommend you don't use cursors at all in triggers. Why
> can't you re-write this and the contents of Add2Summary as set-based
> SQL?
> If you need more help then please come back with DDL, sample data
> INSERT statements and show your required end result.
> --
> David Portas
> SQL Server MVP
> --
>