Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Error. This is not permitted when the....

Author  Topic 

kiridu
Starting Member

4 Posts

Posted - 2013-02-27 : 18:21:27
Hello I’m getting this error and I can't figure out how to fix it..

Error Message: Subquery retured more than 1 value. This is not permitted when the subquery follows =,!=,<, ect...

In SQL server I want to display all Record with SKU 1404 and 1354, when they enter '1404' in the filter field. below is my query.

thanks in advance.

SELECT CASE WHEN SKU = '1404' THEN
(SELECT SKU
FROM dbo.Table1 AS A
WHERE(SKU IN ('1404', '1354'))) ELSE A.SKU END AS SKU
FROM dbo.Table1 AS A

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-02-27 : 18:33:30
How do you get the user input? Usually that comes in in a variable like shown below:
DECLARE @sku VARCHAR(32) = '1404'; -- this is the user input

SELECT
a.SKU
FROM
dbo.Table1 a
WHERE
(@sku = '1404' AND a.SKU IN ('1404','1354'))
OR @sku = SKU
Go to Top of Page
   

- Advertisement -