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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:49:04+00:00 2026-05-31T20:49:04+00:00

When I use BCP data into database, the trigger is not fired. What should

  • 0

When I use BCP data into database, the trigger is not fired.
What should I do to make the trigger useful? Can I merely update the data without changing values?

     try
        {
            //get all data
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + excelFile + ";" + "Extended Properties=Excel 8.0;";
            OleDbConnection conn = new OleDbConnection(strConn);
            conn.Open();
            string strExcel = "";
            strExcel = string.Format("select * from [{0}$] where xh<>''", sheetName);
            OleDbDataAdapter oda = new OleDbDataAdapter(strExcel, strConn);
            oda.Fill(ds, sheetName);

            //BCP data
            using (SqlBulkCopy bcp = new SqlBulkCopy(connectionString))
            {
                bcp.SqlRowsCopied += new SqlRowsCopiedEventHandler(bcp_SqlRowsCopied);
                bcp.BatchSize = 100;//the speed of import
                bcp.NotifyAfter = 100;
                bcp.DestinationTableName = sheetName;//target table
                bcp.WriteToServer(ds.Tables[0]);
            }
        }
   catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);
        }

The trigger is following.

create trigger getAge
on tablename
for insert ,update
as
if update(birthday)
update tablename set age=DateDiff(year,birthday,getdate())
go

  • 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-05-31T20:49:06+00:00Added an answer on May 31, 2026 at 8:49 pm

    Check this MSDN article: http://msdn.microsoft.com/en-us/library/ms187640.aspx

    Using bcp, triggers are disabled by default. To enable it, use the following argument:

    -h "FIRE_TRIGGERS"
    

    When working with the SqlBulkCopy class provided by .NET, use the SqlBulkCopyOptions enum to enable trigger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Obviously I can use BCP but here is the issue. If one of the
I want to use BCP to load into a SQL Server 2005 table with
I'm trying to use the SQL Server bcp utility to import a text file
USE master GO DECLARE @DbName nvarchar(MAX) SET @DbName = N'DataBase' ALTER DATABASE @DbName SET
I need to export some data using SQL Server 2000's BCP utility. Sometimes my
When would we use a format file for bcp?
Problem: How to most efficiently move data from an array into a SQL Server
Use: The user searches for a partial postcode such as 'RG20' which should then
Use case: we have some project meta-data files which we want tracked, but are
Is there any solution for bulk delete in SQL Server? I can't use TRUNCATE

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.