FakeTable with tSQLt remove triggers

Posted by user1454695 on Stack Overflow See other posts from Stack Overflow or by user1454695
Published on 2012-11-25T18:14:54Z Indexed on 2012/11/25 23:04 UTC
Read the original article Hit count: 403

Filed under:
|

I have jsut started to use tSQLt and is about to test a trigger. I call the FakeTable procedure and do my test but the trigger is not executed. If don't use FakeTable the trigger is executed. That seems to be really bad and I canät find any info that there is any method to readded them.

Then I thought the triggers are removed by FakeTable but I can recreate them after the call and did the following code in my test:

DECLARE @createTrigger NVARCHAR(MAX);
SELECT @createTrigger = OBJECT_DEFINITION(OBJECT_ID('MoveDataFromAToB'))    
EXEC tSQLt.FakeTable 'dbo.A';
EXEC(@createTrigger);

I got the following error: "There is already an object named 'MoveDataFromAToB' in the database.{MoveDataFromAToB,14} (There was also a ROLLBACK ERROR --> The current transaction cannot be committed and cannot be rolled back to a savepoint. Roll back the entire transaction.{Private_RunTest,60})"

Anyone that have any experience with tSQLt and know anyworkaround for this problem?

© Stack Overflow or respective owner

Related posts about triggers

Related posts about tsqlt