Vardoj
Vardoj

Reputation: 51

Error SQL03120 on Trigger scripts in 2008 DB Project

I'm working on adding a database project in VS2010. I created a SQL 2008 DB Project, pointed at the development server, and it seems to have generated all of the appropriate schema objects. However, all of the CREATE TRIGGER scripts have the following error:

SQL03120: Cannot find element referenced by the supporting statement

Googling that error message doesn't return much, and seems to point to scripts using ALTER instead of CREATE which isn't the case here. This is an example of one of the scripts:

CREATE TRIGGER [TR_t_TABLE_TRIGGERNAME] ON [content].[t_TABLE]
FOR INSERT
AS
BEGIN
    IF ( SELECT COUNT(*) FROM inserted) > 0 
        BEGIN
            DECLARE @columnBits VARBINARY(50)
            SELECT @columnBits = COLUMNS_UPDATED() | CAST (0 AS BIGINT)
            INSERT  INTO [history].[t_TABLE]
                    (
                       ....    
                    )
                    SELECT 
                       ....
                    FROM inserted
        END
END
GO
EXECUTE sp_settriggerorder @triggername = N'[Content].[TR_t_TABLE_TRIGGER]', @order = N'last', @stmttype = N'insert';

The line that Visual Studio is attributing the error to is the last line executing the system proc. What stands out to me is that none of the object exist in the dbo schema. The table is in the Content schema and it has a matching table in the History schema. It would seem like the [Content] and [History] qualifiers would be resolvable though. Can't figure this one out...

Upvotes: 4

Views: 801

Answers (1)

user489998
user489998

Reputation: 4521

Since this post comes up when you search for the above error on Google: another reason for this error is if you've got a stored procedure in a database project which specifies ALTER PROCEDURE rather than CREATE PROCEDURE.

Upvotes: 2

Related Questions