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 8339499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:54:00+00:00 2026-06-09T04:54:00+00:00

I am using SQL Server 2008 R2 and I want to create a stored

  • 0

I am using SQL Server 2008 R2 and I want to create a stored procedure that deletes from two tables using a paramater (id).

This is the stored procedure:

CREATE PROCEDURE [dbo].[sp_deleteDecision]
@ID int
AS

DELETE FROM [dbo].[tblDecisionInvolvement] as di
WHERE di.DecisionId = @ID
DELETE FROM [dbo].[tblDecision] as d
WHERE d.Id =@ID

GO

This is the error I get when I try to create it:

Msg 156, Level 15, State 1, Procedure sp_deleteDecision, Line 6
Incorrect syntax near the keyword ‘as’.
Msg 156, Level 15, State 1, Procedure sp_deleteDecision, Line 8
Incorrect syntax near the keyword ‘as’.

Note that changing the DELETE FROM to

SELECT * FROM 

it works.

Is it even possible to delete something using parameters?

Ty.

  • 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-09T04:54:01+00:00Added an answer on June 9, 2026 at 4:54 am

    You aren’t allowed to introduce an alias at that part of a DELETE statement – nor do you need one in this case:

    USE ChessDb01
    GO
    CREATE PROCEDURE [dbo].[sp_deleteDecision]
    @ID int
    
    AS
    
    DELETE FROM [dbo].[tblDecisionInvolvement]
    WHERE DecisionId = @ID
    DELETE FROM [dbo].[tblDecision]
    WHERE Id =@ID
    
    GO
    

    For a more complex query, you might want to use an alias, but note that (confusingly), the DELETE will have two FROM clauses – and you can only introduce the alias in the second one:

    DELETE FROM di
    FROM [dbo].[tblDecisionInvolvement] di
                inner join
          AnotherTable tab
               on
                  di.Column = tab.Column2
    WHERE tab.Column99 = @Value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2008. I have a database table that looks like this
I am using SQL Server 2008 R2. I have imported 2 tables from excel
hi i am using SQL Server 2008, want to create a view to list
I want to create a program, that will use SQL Server 2008 database. During
I am using SQL Server 2008 R2 and I want to add a non-clustered
I am using SQL Server 2008 Enterprise version. I want to know if I
I want to develop a generic CRM application using SQL Server 2008. The application
I want to write a code to backup my Sql Server 2008 Database using
I am using SQL Server 2008 R2, I am trying to create a dataset
I'm using SQL Server 2008. Is it possible to create a script to loop

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.