473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help on Error:Only one expression can be specified in the select list when the subque

Hi Everyone

I'm trying to create a stored procedure that will delete groups that are in-active for a month.

Table description i have two table which are linked together using groupID, when creating the group group info is stored into the group table including the date group was created, and when posting comment to the group, content is stored into the groupPost table.

I have the isDelete column on both table which is a bit data-type - for the group row to be de-actived i need to set is delete column to true.

where is my stored procedure:
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE dbo.DeleteInActiveGroups
  2. AS
  3. UPDATE 
  4.         dbo.GroupPost
  5. SET 
  6.         dbo.GroupPost.isDeleted = 1
  7. WHERE
  8.         dbo.GroupPost.GroupID
  9. IN
  10. (
  11.         SELECT
  12.                 *
  13.         FROM
  14.                 dbo.Groups
  15.         WHERE
  16.                 dbo.Groups.DateCreated < DATEADD(MONTH, -1, GETDATE())
  17.         AND 
  18.                 Groups.UserID <> 37 OR Groups.UserID <> 36
  19. )
  20.  
I keep on getting an error:Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

Any help will be appreciated. Thanks in advance
Jan 29 '09 #1
3 5831
Atli
5,058 Expert 4TB
Hi.

That doesn't look like MySQL code to me.
Which SQL server are you using?
Microsoft's SQL Server perhaps?

Let me know and I'll move this to the proper forum.
Jan 29 '09 #2
Apologies, i didn't notice i'v posted to the wrong forum, it's SQL, I'm currently using SQL Server 2005, Enterprise Edition
Feb 4 '09 #3
ck9663
2,878 Expert 2GB
Change your subquery to:

Expand|Select|Wrap|Line Numbers
  1. SELECT GroupID
  2. FROM dbo.Groups
  3. WHERE
  4. dbo.Groups.DateCreated < DATEADD(MONTH, -1, GETDATE())
  5. AND 
  6. Groups.UserID <> 37 OR Groups.UserID <> 36
  7.  
IN have some problems handling NULL. Read more about it here

Happy Coding!


-- CK
Feb 4 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Justin | last post by:
Greetings all, I'm receiving this error when I attempt to pull data, in the form of an ArrayList out of a Session. ArrayList al = new ArrayList(); al = (ArrayList)Session; // error here ...
5
by: Alan Silver | last post by:
Hello, I have an ASP.NET page where I am grabbing an SqlDataReader and using it to populate some controls on the form. Amongst the fields pulled out of the table are two integer fields, which I...
4
by: Web Team | last post by:
Hi All, When I run the below code, I get error 'Specified cast is not valid' on line 163 Dim Address As OldInfra.BS7666.Address = BS7666AddressCollection.GetSingleAddress(str_UPRN) 164...
0
by: Genival P.Carvalho | last post by:
Hello folks, First sorry my bad english. I will try to implement a IExtenderProvider + Verbs (Designer). When compile tha follow code its compile fine, but whem drag resulting componet under form...
6
by: Tom McL. | last post by:
I'm trying to move a program that was designed using Visual Studio 2003 and (Visual Basic) into Visual Studio 2005. When it runs I get the following warning in the Error List Window and I'm not...
0
by: guy | last post by:
another intermittent problem... after a while when doing a build the error list 'Error' and 'Warning' icons disappear from the error lines but are still visible in the heading (between Error...
3
by: keithb | last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding the Visible propery of a hyperlink control to a DataTable text field. The error goes away if I replace the data binding...
5
by: Reshmi Jacob | last post by:
Hello Can I have more than one variable assign to a select clause in a trigger. How? My stmt creates an error SELECT FLD1 into VAR1, FLD2 into VAR2 FROM MYTABLE; ERROR shown at the second...
11
by: kimiraikkonen | last post by:
Hello, I'm very new to C# and just installed VC# 2005 express edition and i have VB 2005 express installed previously. But i saw a thing which may be called as a "Visual C# 2005 express" bug? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.