I want to assign multiple values to a variable from a SELECT statement in a stored procedure. The code goes like this
DECLARE @ProjectExecutionPlanId INT=NULL
SELECT @ProjectExecutionPlanId = (SELECT [ID] FROM [dbo].[ProjectExecutionPlan]
WHERE ProjectDetailID=@PID)
@PID in the input to the stored procedure.
The SELECT statement returns multiple values. So I am getting error.
@ProjectExecutionPlanIdTOP 1to the inner select, or try and understand why you are getting multiple values.