On Tue, 12 Feb 2008 15:43:14 +0000, Paul Cowan <[EMAIL PROTECTED]> wrote:
>Hi all, >To cut a long strory short I have a trigger where I want to update some totals on another table. >THe thing is I have the following line: >SET @roleType = (SELECT cc.calltreecontactroleid FROM CallTreeContacts cc WHERE cc.[Uid] IN (SELECT [Uid] FROM inserted)) >This works if I update one row but if I update multiple rows I get the following error because I have more than one recored in the Inserted table. >Subquery returned more than 1 value > The problem is because you're trying to assign multiple results to a single variable. If you want to process each roleType from the inserted set then you could use a cursor but this isn't recommended in a trigger. The recommendation is to rowset logic (a single SQL statement) instead of a cursor. Maybe the following MSDN page will be helpful: http://msdn2.microsoft.com/en- us/library/aa175005(SQL.80).aspx =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com