472,126 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 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. )
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 5765
5,058 Expert 4TB

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
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
IN have some problems handling NULL. Read more about it here

Happy Coding!

-- CK
Feb 4 '09 #4

Post your reply

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

Similar topics

1 post views Thread by Justin | last post: by
5 posts views Thread by Alan Silver | last post: by
4 posts views Thread by Web Team | last post: by
reply views Thread by guy | last post: by
11 posts views Thread by kimiraikkonen | last post: by
reply views Thread by leo001 | last post: by

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.