FKoller
FKoller

Reputation: 13

T-SQL DELETE Statement returns Subquery hint "returns more than one value..."

I have a question on MS SQL's DELETE statement.

I pose the following statement:

DELETE [Database].[dbo].[ADDRESSES]
  WHERE USERGROUP = 'GR_SALES';
GO

The SSMS throws out the following hint: (regular hint, when a subquery returns more than one value:

Message 512, Level 16, Status 1, procedure After Update, row 27

The Subquery returns more than one value...

What is wrong?

Upvotes: 1

Views: 140

Answers (1)

Stuart J Cuthbertson
Stuart J Cuthbertson

Reputation: 438

The words after update in the hint strongly suggests that this table has a trigger being called.

My best guess is that the trigger has both update and delete actions; your DELETE query causes it to fire, at which point SQL Server parses the update action even though it isn't relevant here. If this is correct, running an UPDATE query will probably cause an actual error from within the trigger.

Upvotes: 1

Related Questions