Solved

Create Trigger Error Invalid Object Name

Posted on 2007-03-19
6
1,776 Views
Last Modified: 2008-01-09
I have my trigger setup and ready to go, but when I try to create it I get the error:

Msg 208, Level 16, State 4, Procedure dbo.STEP1push, Line 10
Invalid object name 'dbo.CO_DES_QUEUE'.

That table exists, so I have no idea why this is not working.  I used the create trigger template in SQL Server Management Studio.  It should be noted, however, that this is on SQL Server 2000.

Here is the trigger:

-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:            Paul Huff
-- Create date: 03/19/2007
-- Description:      On INSERT (new job being configured) will create an OLE
--                        object to our strongly named .NET component and call it.
--                        This component is the publisher object in our design
--                        automation process which uses Subscriber/Publisher pattern
--                        to push new jobs to the baby ENG servers.
-- =============================================
CREATE TRIGGER "dbo.STEP1push"
   ON "dbo.CO_DES_QUEUE"
   AFTER INSERT
AS
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

    -- DECLARE needed variables
      DECLARE  @ExecutionResult INT, @errorSource VARCHAR(100), @errorDescription VARCHAR(100)
                   , @result VARCHAR(200), @hnd INT, @quoteNumber VARCHAR(10), @designID INT
 
      -- Get design id from INSERT command and then get the quote number
      SELECT @designID = "DESIGN_ID" FROM "INSERTED"
      SELECT @quoteNumber = "DESIGN_INPUT" FROM "dbo.CO_DES_INPUT" WHERE "INPUT_NAME" = 'QuoteNumber' AND "DESIGN_ID" = @designID

      -- EXECUTE the system stored procedure to create our OLE object and
      -- call the appropriate method from the .NET dll.
      EXEC @ExecutionResult = sp_OACreate 'STEP1.AutoDesign.Publisher.CDesignPush', @hnd OUTPUT
      IF (@ExecutionResult <> 0)
      BEGIN
              EXEC sp_OAGetErrorInfo @hnd, @errorSource OUTPUT, @errorDescription OUTPUT
              SELECT @errorSource, @errorDescription
      END
      
      -- EXECUTE the system stored procedure to call the method to execute a push
      EXEC @ExecutionResult = sp_OAMethod @hnd, 'pushDesign', @result OUTPUT, @designID, @quoteNumber
      IF (@ExecutionResult <> 0)
      BEGIN
              EXEC sp_OAGetErrorInfo @hnd, @errorSource OUTPUT, @errorDescription OUTPUT
              SELECT @errorSource, @errorDescription
      END
      
      EXEC @ExecutionResult = sp_OADestroy @hnd
      IF (@ExecutionResult <> 0)
      BEGIN
              EXEC sp_OAGetErrorInfo @hnd, @errorSource OUTPUT, @errorDescription OUTPUT
      
              SELECT @errorSource, @errorDescription
      END
      
      SELECT @result
      

END
GO

0
Comment
Question by:phuff34
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:lahousden
ID: 18752069
<<...That table exists...>> - are you sure, however, that it is indeed owned by "dbo"?  If it is owned by another user then you will need to change the "dbo" to the other user name.
0
 

Author Comment

by:phuff34
ID: 18752104
Yes it does exist and it is owned by dbo.  In fact, I just dragged the table from the tree view into the code to eliminate typos.
0
 

Accepted Solution

by:
phuff34 earned 0 total points
ID: 18752190
Problem solved.

I had to add a

use [Concept608] (which is the database name)

to the beginning.  You would have thought it would have been assumed.  Oh well.  Thanks anyway
0
 
LVL 10

Expert Comment

by:lahousden
ID: 18753494
No wurries! ;)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now