473,574 Members | 2,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

4 New Member
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. )
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 5838
5,058 Recognized Expert Expert

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
4 New Member
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
2,878 Recognized Expert Specialist
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
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

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 How can this cast be invalid, when the session data IS an ArrayList??
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 am trying to cast as strings so they can be displayed in a Literal control. I am using the following code (heavily edited for clarity) ... if...
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 Dim easting As Integer = Address.Easting
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 i gain a error: Specified Cast Is Not Valid :( Code. #Region "NameSpaces Area"
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 sure how to correct it. The program runs fine except for the warning. The warning puts a green squiggle line under MyRecord in the (Private Sub...
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 List and Description) the column they should appear in is blank. once gone they stay gone untill VS is reloaded any ideas?
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 statement with "true" or "false". This code causes the error: <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#...
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 INTO. I tried to make it a cursor and it was successful .
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? For example, in VB 2005 express while i was coding, if there's a coding error, errors are displayed in error list below the screen immediately during...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.