sql where Query error as Only one expression can be specified in the select list when the subquery is not introduced with EXISTS
While writing Stored procedure why I'm getting this error
Create Proc sp_generateToken
As
declare @typeofcust varchar(10)
declare @maxnumber int
Begin
set @typeofcust = (select * from Client where Client_Id = 1);
set @maxnumber= (select coalesce (MAX(cust_RegiId),0) from Customer_registeraion)
End
Please help me why im getting this error
Solution 1:
The issue is this line here:
set @typeofcust = (select * from Client where Client_Id = 1);
Like my comment says you're trying to return everything from that table where Client_Id = 1
and trying to put it into a varchar
...
I think, (if you are simply trying to get the typeofcust), you should return the TOP(1) typeOfCust
or whatever the column is from the Client table.
However, if you are wanting to actually return everything, you'd have to create a temp table and do a select into such as:
INSERT INTO #temp
(
// columns
)
SELECT
(
// Columns
)
FROM Client
WHERE Client_Id = 1