SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Error. This is not permitted when the....
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kiridu
Starting Member

USA
4 Posts

Posted - 02/27/2013 :  18:21:27  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3760 Posts

Posted - 02/27/2013 :  18:33:30  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000