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

  • Home
  • SEARCH
  • 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 8584357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:45:19+00:00 2026-06-11T21:45:19+00:00

I read this Help with SQL Server Trigger to truncate bad data before insert

  • 0

I read this Help with SQL Server Trigger to truncate bad data before insert but not solve my issue when is about stored procedure.

update

Because of my issue Why cannot create global temporary table or truncate it when call a stored procedure from C# code? when truncate table from stored procedure when it is called from C# code.

end update

The stored procedure is

ALTER PROCEDURE [dbo].[aProcedure]
  @val1 VARCHAR(255),
  @val2 VARCHAR(255),
  ...
AS 
BEGIN
   SELECT @sql = '//Do SELECT statement'

    INSERT INTO dbo.MyTable(....)

    SELECT @paramList = ' /*list of parameters*/';

    EXEC sp_executesql @sql, @paramList, ... parameters
END

And the trigger I used (I’m beginner in SQL)

CREATE TRIGGER MyTrigger ON dbo.MyTable
FOR INSERT
AS
BEGIN
    TRUNCATE dbo.MyTable
END

How do trigger, when from stored procedure the values are inserted into dbo.MyTable, which truncate my table first and after that make INSERT operation ?

I read the documentation from MSDN and CodeProject.

Thank you

  • 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-11T21:45:20+00:00Added an answer on June 11, 2026 at 9:45 pm

    In the stored procedure itself truncate the table. No need to write a trigger.
    Trigger will slow down your process

    ALTER PROCEDURE [dbo].[aProcedure]
      @val1 VARCHAR(255),
      @val2 VARCHAR(255),
      ...
    AS 
    BEGIN
       SELECT @sql = '//Do SELECT statement'
    
         TRUNCATE table  dbo.MyTable -- < add truncate here
        INSERT INTO dbo.MyTable(....)
    
        SELECT @paramList = ' /*list of parameters*/';
    
        EXEC sp_executesql @sql, @paramList, ... parameters
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen this link, but with no help: How can I determine installed SQL
i store doc file into sql server data base i want view this file
We can easily work with SQL Server databases with the help of System.Data.SqlClient library
We are pulling a huge data from sql server DB. It has around 25000
I am trying to write a SQL Server query but have had no luck
I'm sure this would have been asked before, but I'm very confused! Say I
I am having an issue with sql server precision. I have the following queries:
I'm not a good SQL programmer, I've got only the basics, but I've heard
I try reading data from SQL Server 2005 and filling it in a TableAdapter
I use openquery syntax to read the data from a linked server. SELECT *

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.