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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:00:01+00:00 2026-05-28T11:00:01+00:00

I have a query like this: use DataIncremental go DECLARE @row_terminator CHAR; SET @row_terminator

  • 0

I have a query like this:

use DataIncremental
go
DECLARE @row_terminator CHAR;
SET @row_terminator = CHAR(10); -- or char(10)

BEGIN TRAN tran2


DECLARE @stmt NVARCHAR(2000);
SET @stmt = '
  BULK INSERT accn_adjustments
   FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201112302112.txt''
   WITH 
      (
        firstrow=2,
FIELDTERMINATOR = ''|''  ,
ROWS_PER_BATCH=10000
   ,ROWTERMINATOR='''+@row_terminator+'''
   )'
exec sp_executesql @stmt;
SET @stmt = '
  BULK INSERT accn_adjustments
   FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201112312112.txt''
   WITH 
      (
        firstrow=2,
FIELDTERMINATOR = ''|''  ,
ROWS_PER_BATCH=10000
   ,ROWTERMINATOR='''+@row_terminator+'''
   )'
exec sp_executesql @stmt;
SET @stmt = '
  BULK INSERT accn_adjustments
   FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201201022101.txt''
   WITH 
      (
        firstrow=2,
FIELDTERMINATOR = ''|''  ,
ROWS_PER_BATCH=10000
   ,ROWTERMINATOR='''+@row_terminator+'''
   )'
exec sp_executesql @stmt;
SET @stmt = '
  BULK INSERT accn_adjustments
   FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201201032101.txt''
   WITH 
      (
        firstrow=2,
FIELDTERMINATOR = ''|''  ,
ROWS_PER_BATCH=10000
   ,ROWTERMINATOR='''+@row_terminator+'''
   )'
exec sp_executesql @stmt;

The reason I put begin tran tran2 is to ensure that if there are errors I can just do a rollback

I ran the code and the message I got was "query completed with errors"

SSMS did NOT state that some rows were inserted as it usually does.

When I tried to do a rollback tran tran2, it said that that transaction never began

So my question is, were rows committed to the database or not?

If not, then why did it state “query completed with errors” shouldnt it just have said query did not complete due to errors?

  • 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-28T11:00:01+00:00Added an answer on May 28, 2026 at 11:00 am

    Description

    Since SQL Server 2005 you can use error handling using TRY CATCH

    TRY…CATCH (Transact-SQL) Implements error handling for Transact-SQL that is similar to the exception handling in the Microsoft Visual C# and Microsoft Visual C++ languages. A group of Transact-SQL statements can be enclosed in a TRY block. If an error occurs in the TRY block, control is passed to another group of statements that is enclosed in a CATCH block.

    Sample

    BEGIN TRY
        BEGIN TRANSACTION
    
         -- do something
    
        COMMIT TRAN -- Transaction successfull, commit!
    END TRY
    BEGIN CATCH
        IF @@TRANCOUNT > 0
            ROLLBACK TRAN --RollBack if error occured
    END CATCH
    

    More Information

    • Microsoft TechNet – TRY…CATCH (Transact-SQL)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have query like this DECLARE @A INT SET @A = 22 SELECT Moo,
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have a simple query like this.. USE AdventureWorks; GO SELECT DaysToManufacture, AVG(StandardCost) AS
I use SQL Server 2005 and I have a query like this : INSERT
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE
I have a query like this: SELECT t1.id, (SELECT COUNT(t2.id) FROM t2 WHERE t2.id
I have a query like this (Mysql 5.X, PHP - formatted for legibility) $query
I have a query like this: SELECT COUNT(*) AS amount FROM daily_individual_tracking WHERE sales
Say I have a query like this: one two three, if I replace with
Say I have a query like this: select ((amount1 - amount2)/ amount1) as chg

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.