I have the following table:
CREATE TABLE [dbo].[proposalReviewAction]
(
[proposalReviewActionID] [INT] IDENTITY(1,1) NOT NULL,
[proposalPackageID] [INT] NULL,
[approvalTypeID] [INT] NULL,
[comments] [VARCHAR](2000) NULL,
[reviewedByID] [INT] NULL,
[reviewedDate] [DATETIME] NULL
) ON [PRIMARY]
I want to return each record that has an approvalTypeID = 100 and use the proposalPackageID in another process that moves the data from the proposal table to the project table.
I considered using a WHILE loop, but everyone seems to favor processing a dataset but I cannot find any way to do this in SQL/T-SQL.
I found an example of a WHILE loops and modified it ...
WHILE (SELECT[approvalTypeID] FROM [proposalReviewAction]) = 100
BEGIN
DECLARE @ppID AS INT ;
SELECT [proposalPackageID] AS ppID, [approvalTypeID] AS atID
FROM [proposalReviewAction]
IF (SELECT [approvalTypeID] AS atID FROM [proposalReviewAction]) = 100
PRINT @ppID
ELSE
BREAK
END
PRINT 'I got to the print statement';
... but I get the following error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Then, it prints the "PRINT" statement.
Any help is appreciated...
Bob