When adding a record to a table, the first record is added, and when adding a second one, it shows that "the subquery returned more than one value". There is a trigger on the table.
USE [ERP] GO /****** Object: Trigger [dbo].[Заявка_ЖурнаПрих] Script Date: 09.05.2016 18:08:56 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Trigger [dbo].[Заявка_ЖурнаПрих] ON [dbo].[Заявка] FOR insert AS DECLARE @V_Puti nvarchar(50); SET @V_Puti = 'В пути'; SET nocount on while (Select Дата_поступления From Заявка) >= CONVERT (date, GETDATE()) begin Update Заявка Set Статус=@V_Puti where [№-заявки] in(select [№-заявки] from inserted) END
while. I remember I needed a much more cumbersome design. Of course, since then, that may have changed. But after inserting the second record, the query will produce two lines, and only one value can compare the server at a time, which is what it says. - Sergey