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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:05:57+00:00 2026-05-30T02:05:57+00:00

I have a strange problem here, I want to create an emtpy trigger: SET

  • 0

I have a strange problem here, I want to create an emtpy trigger:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER dbo.TestTrigger 
   ON  _TestDB.dbo.test
   AFTER UPDATE
AS 
BEGIN
    SET NOCOUNT ON;
END
GO

If I execute this within SSMS it works perfectly, but if I create a new SQL file within Visual Studio and click “Execute SQL”, then I just get an error message:

Msg 2108, Level 15, State 1, Procedure TestTrigger, Line 13 Erstellen
Trigger kann nicht für ‘_TestDB.dbo.test’ ausgeführt werden, da sich
das Ziel nicht in der aktuellen Datenbank befindet.

Translation:

Msg 2108, Level 15, State 1, Procedure TestTrigger, Line 13 Create
Trigger cannot be executed for ‘_TestDB.dbo.test’, because
the target doesn’t exist in the current database.

SSMS and VS2010 are both connected to the same databaseserver as the same user.

A simple Select * From _TestDB.dbo.test does work within Visual Studio, so the connection to the database should work. But why is it not working for Create Trigger?

  • 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-30T02:05:58+00:00Added an answer on May 30, 2026 at 2:05 am

    As the error implies, triggers must be created in the same database as the underlying target table.

    So ensure that you create the trigger in the same DB (_TestDB) as your dbo.test table

    USE _TestDB
    GO
    
    SET ANSI_NULLS ON GO 
    SET QUOTED_IDENTIFIER ON 
    GO  
    
    CREATE TRIGGER dbo.TestTrigger     
    ON  dbo.test    
    AFTER UPDATE AS  
    BEGIN     
      SET NOCOUNT ON; 
    END 
    GO 
    

    Edit : Just to clarify – a connection is at server instance level, not at database level. By qualifying your table as _TestDB.dbo.test you will be able to access the table even if your current database (catalogue) is currently pointing to a different database.

    Edit : OIC – yes, it means that your current db isn’t “_TestDB”. You’ve also picked up an inconsistency in SQL’s DDL execution. Most of the DDL commands can be successfully executed from a remote database (Including CREATE INDEX), but for some reason, not a trigger. The following highlights the inconsistency (SQL 2008 Express)

    use master
    go
    
    CREATE DATABASE bob
    GO
    
    -- DB_NAME() = master
    CREATE TABLE bob.dbo.SomeTable
    (
        SomeTableId INT NOT NULL,
        AnotherField VARCHAR(50) NULL
    )
    GO -- Success
    
    -- DB_NAME() = master
    CREATE INDEX IX1_SomeTable on bob.dbo.SomeTable(SomeTableId)
    GO -- Success. Note that the index is actually created in bob, not master of course
    
    -- DB_NAME() = master
    ALTER TABLE bob.dbo.SomeTable ADD CONSTRAINT PK_SomeTableId PRIMARY KEY(SomeTableId)
    GO -- Success
    
    -- DB_NAME() = master
    CREATE TRIGGER bob.dbo.SomeTableTrigger -- 'CREATE/ALTER TRIGGER' does not allow specifying the database name as a prefix to the object name.
        ON  bob.dbo.SomeTable
        AFTER UPDATE
    AS
        BEGIN
            PRINT 'Trigger called'
        END
    GO
    
    -- DB_NAME() = master - this is your scenario - 
    CREATE TRIGGER dbo.SomeTableTrigger -- Cannot create trigger on 'bob.dbo.SomeTable' as the target is not in the current database.
        ON  bob.dbo.SomeTable
        AFTER UPDATE
    AS
        BEGIN
            PRINT 'Trigger called'
        END
    GO
    
    USE BOB
    GO
    
    -- DB_NAME() = bob
    CREATE TRIGGER dbo.SomeTableTrigger -- Success
        ON  bob.dbo.SomeTable
        AFTER UPDATE
    AS
        BEGIN
            PRINT 'Trigger called'
        END
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some strange problem with table in Firefox. What I want to create
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I have a strange problem with mod_rewrite, the rules that are relevant here are:
I have a strange problem I don't understand... I want to do a PopupWindow
I am having a kinda strange problem. Here is the situation. I have a
I have a very strange problem with a ColorAnimation. What I want to do
I have a super strange problem. I want a Textured window to have it
I have strange problem with the delay function here using the HTML function with
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed
i have strange problem doing reporting: i have numerous clients with different issued invoices.

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.