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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:11+00:00 2026-05-23T12:31:11+00:00

We are seeing ‘interesting behavior with our SQL Sever Database. We have a merge

  • 0

We are seeing ‘interesting behavior with our SQL Sever Database. We have a merge statement which selects a table X. In the match clauses there is a subselect to table X. When we execute the stored procedure from the SQL Server Tools it works fine. But when executed from IPC (an ETL Tool) we get an exception Invalid object name 'X'.

So far nothing special as I understand there can get lots of things wrong with permissions and stuff.

The strange thing: The merge statement is in a try block and in the catch block the error message gets written into the table X via an update statement! How is this possible when Sql Server complains it can’t find a table X?

Also everything works fine with another stored procedure which is constructed in the same way (via code generation) but on a different set of tables.

The code looks like this

    merge ...
    using
    (select ...
    from dbo.X
    where ...
    when not matched by target 
    and not exists (select 1 from dbo.X q2 where ...)
    then insert (...
    )
    values (...
    )
    when matched and q.ACTION='D'
    then delete
    when matched AND NOT exists (select 1 from dbo.X q3 where ...)
    then update 
    set
      ...

    OUTPUT $action INTO @l_SummaryOfChanges;
    -- Query the results of the table variable.
    SELECT ACTION, COUNT(*) AS CountPerChange
    FROM @l_SummaryOfChanges
    GROUP BY ACTION;
  end try
  begin catch
    update dbo.X
    set LAST_ERROR_MSG=ERROR_MESSAGE(), ERROR_COUNTER=ERROR_COUNTER+1
    where SYNC_ID=@l_SyncID
  end catch

Any ideas what is going on?Invalid object name ‘sync$_tabTeiledaten’.

  • 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-23T12:31:12+00:00Added an answer on May 23, 2026 at 12:31 pm

    We found it. gbn’s question triggered the realization that the usage of X had nothing to do with the exception. In fact on target table of the merge was a trigger which is referencing X but from a different schema without actually specifying the schema.

    May somebody will benefit from the way we debugged this shit:

    • we duplicated X with a new name (Y) and still got the error message saying ‘Invalid object name ‘X’. At that point we thought we might reference a view or something so ..
    • we removed all the columns (there where lots of) from the merge statement, except those which where necessary due to Not Null Constraints. The problem persisted
    • We removed 1 of the branches of the merge statement at a time. The problem persisted.
    • we removed the complete merge statement. The error was gone. At that point we realized that something fishy might go on with the target table.
    • On inspection we found the trigger from hell.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm seeing an interesting behavior difference between my instance and my boss's instance of
Seeing some strange behavior, whereby connecting to Oracle database, and then calling external function,
Seeing as though our team maintain an Intranet which has clients users guaranteed to
Seeing as Java doesn't have nullable types, nor does it have a TryParse(), how
Seeing some strange things; help is being solicited. I have a query, like so:
When seeing SQL code on the internet and in manuals there seems to vary
After seeing several threads rubbishing the regexp method of finding a term to match
Seeing all the UNIX guys have memcache (PHP, Python, etc.), are the .NET libraries
I am seeing very, VERY strange behavior when I run certain reports: >> p
After seeing the 13th Floor back in the day I have been obsessed to

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.