I have a table that I need to insert multiple rows using data from two other tables I am trying the following
SET IDENTITY_INSERT [dbo].[JobTypeUplifts] ON
INSERT INTO [dbo].[JobTypeUplifts]
(
[ID]
,[JobTypeID]
,[CustomerID]
,[MarkUpPerc]
,[PriceSQM]
,[Ref])
VALUES
(50
,(select ID from JobType where code like '%-d')
,(select ID from Customers)
,15
,0
,''
)
GO
But I get the error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I have multiple Job Types and multiple customers.
How do I overcome the problem?
select ID from JobType where code like '%-d'returns values 1, 10, 101, 493? That is what is happening, one of those subqueries is returning multiple records and the insert statement can't assume that the first returned value should be inserted.selectto outer loop arund theinsertstatement,