delete statement using store procedure

Shambhu Rai 1,381 Reputation points

how can use delete statement for SP

create table table1( col int,col2 varchar(200))

create sp as


delete from table1 where condition


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,234 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,403 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,231 questions
{count} votes

Accepted answer
  1. Michael Taylor 43,971 Reputation points

    Deleting rows from a table inside a sproc works the same as you would from writing the raw SQL in SSMS. Can you be more specific about what you're trying to do and why a sproc has any impact on that?

    -- Outside sproc: delete any row where col > 100
    DELETE FROM table1 WHERE col > 100
    -- Inside sproc
    CREATE PROCEDURE DeleteFromTable1 AS
       DELETE FROM table1 WHERE col > 100

    If you want it parameterized then you can do that as well. Just add the parameter to the sproc declaration and use the parameter inside the query just like you would inside any regular SQL script.

    0 comments No comments

0 additional answers

Sort by: Most helpful