Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql server error 512

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-04-21 : 08:06:47
Spencer writes "I have a problem related to sql server error 512 which is Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

I am hoping you can help me to understand why a query is failing in sql server 2000 but works in sql server 7.0. A table has the following trigger on it:

CREATE TRIGGER TimeTableInserted
ON Time_Table
FOR UPDATE
AS
Update Time_Table set
last_update_dt = GetDate()
Where empl_index = (Select empl_index from Inserted) and
time_date_entered = (select time_date_entered from inserted) and
task_index = (select task_index from inserted) and
time_type = (select time_type from inserted) and
time_shift = (select time_shift from inserted)

I am trying to run a update query like this in Query Analyzer:

update time_table
set time_type = 'S'
where empl_index = 3000
and time_date_entered > '2003-04-03'

Can you tell me why it is failing and what I can do to fix it so that I can run the update query with the trigger still in place? Many thanks in advance.

Spencer"

samsekar
Constraint Violating Yak Guru

437 Posts

Posted - 2003-04-21 : 08:38:13
Try This :

ALTER TRIGGER TimeTableInserted
ON Time_Table
FOR UPDATE
AS
Update Time_Table set last_update_dt = GetDate()
FROM TIME_TABLE T INNER JOIN INSERTED I ON
T.empl_index = I.empl_index and
T.time_date_entered = I.time_date_entered and
T.task_index = I.task_index and
T.time_type = I.time_type and
T.time_shift = I.time_shift
GO


Sekar
~~~~
Success is not a destination that you ever reach. Success is the quality of your journey.
Go to Top of Page

spencey
Starting Member

1 Post

Posted - 2003-04-24 : 06:39:22
That works perfectly. Thanks Sekar.

Spencer

Go to Top of Page
   

- Advertisement -