Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8832325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:30:12+00:00 2026-06-14T08:30:12+00:00

I have a stored procedure where I need to run three separate SELECT statements

  • 0

I have a stored procedure where I need to run three separate SELECT statements and store the result in a variable.

I tried something like this:

SELECT @tier1MenuIds = Id
FROM TheGateKeeper.NavigationTier1
WHERE ([Page Name] = @currentSlug)

SELECT @tier2MenuIds = Id
FROM TheGateKeeper.NavigationTier2
WHERE ([Page Name] = @currentSlug)

SELECT @tier3MenuIds = Id
FROM TheGateKeeper.NavigationTier3
WHERE ([Page Name] = @currentSlug)

But it gives me an error saying

Incorrect syntax near ‘(‘.

The statement works if I remove the bottom two SELECTs. Any other options?

Edit: I am using SQL Server. Here is the full code:

CREATE PROCEDURE [TheGateKeeper].[editContent]
@description nvarchar(300),
@content nvarchar(MAX),
@title nvarchar(50),
@dateModified date,
@headerImageName nvarchar(100),
@slug nvarchar(50),
@id int

AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @currentSlug as nvarchar(100);
    DECLARE @tier1MenuIds as int;
    DECLARE @tier2MenuIds as int;
    DECLARE @tier3MenuIds as int;

    /* Check if the post exists */
    SELECT @currentSlug =   Slug
    FROM         TheGateKeeper.Posts
    WHERE     (Id = @id)

    IF (@@ROWCOUNT = 1)
    BEGIN
    /* Temporarily unlink all menu items linking to post */
    SELECT @tier1MenuIds = Id
    FROM TheGateKeeper.NavigationTier1
    WHERE ([Page Name] = @currentSlug)

    SELECT @tier2MenuIds = Id
    FROM TheGateKeeper.NavigationTier2
    WHERE ([Page Name] = @currentSlug)

    SELECT @tier3MenuIds = Id
    FROM TheGateKeeper.NavigationTier3
    WHERE ([Page Name] = @currentSlug)

    /* Update the post in the database */
    UPDATE Posts
    SET (Description = @description, [Content] = @content, Title = @title, [Date Modified] =@dateModified, HeaderImageName = @headerImageName, slug =@slug)
    WHERE id = @id

    RETURN 1

    END

    ELSE
    BEGIN
    RETURN 0
    END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:30:13+00:00Added an answer on June 14, 2026 at 8:30 am

    Remove the parentheses from your UPDATE statement; they are unnecessary.

    Your update statement should be:

    UPDATE Posts
    SET Description = @description, [Content] = @content, Title = @title, 
        [Date Modified] =@dateModified, HeaderImageName = @headerImageName, 
        slug =@slug
    WHERE id = @id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have stored procedure in my database and i need to look up a
I have a dynamic SQL statement I've created in a stored procedure. I need
I have a stored procedure as follows: CREATE PROC [dbo].[Incidents] (@SiteName varchar(200)) AS SELECT
I have a stored procedure in which if I write the following query without
I have a stored procedure which update a table based on such calculation and
I have a stored procedure in oracle which is using cursor.Its fetching the data
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to
I have a stored procedure which returns sys_refcursor and I am trying to fetch
I have a stored procedure in mysql . In it i am selecting some
I have a stored procedure (SP) in oracle: CREATE OR REPLACE PROCEDURE SP_SEL_LOGIN_INFO (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.