I have created a stored procedure as follow:
Create Procedure sp_ADD_USER_EXTRANET_CLIENT_INDEX_PHY
(
@ParLngId int output
)
as
Begin
SET @ParLngId = (Select top 1 ParLngId from T_Param where ParStrNom = 'Extranet Client')
if(@ParLngId = 0)
begin
Insert Into T_Param values ('PHY', 'Extranet Client', Null, Null, 'T', 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL)
SET @ParLngId = @@IDENTITY
End
Return @ParLngId
End
So I set a variable called @ParLngId, check to see whether a table contains such data, and if it does, return the value; otherwise, I insert one and return the variable containing the Id of the inserted line. However, it now displays a SqlException:
Subquery returned more values. This is not permitted when the subquery follows =,! =, <, <=,>,> = Or when used as an expression.
Does somebody have a solution?