Trigger not working on Sql 2008 server database from my laptop?


There are Entered_date and Enetered_by fields on each of tables.
The production database is on the network server. Those two fields are populated fine.
But when I test my application against a test database server on my laptop.
Two fields are not populated.

Two fields are populated by a trigger from this:

ALTER TRIGGER [dbo].[AuditIns_tblxxxx]
   ON [dbo].[tblxxxx]


      update [dbo].[tblxxx]
      set Entered_date = current_timestamp, Entered_By = system_user
      from inserted i
      INNER JOIN [dbo].[tblxxx] t on i.[IdGuid] = t.[IdGuid];


So it looks like this line is not working when I run my sql server on my laptop.
set Entered_date = current_timestamp, Entered_By = system_user

Any suggestion as why it is not working?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dkim18Author Commented:
It looks like the problem is the trigger is not running.
The trigger might be disabled on the test database.  Run the following query to verify.  The is_disabled column should be 0 (zero) if the trigger is enabled.
  FROM [YourDatbase].[sys].[triggers]
  WHERE Name = 'AuditIns_tblxxxx'

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dkim18Author Commented:
It didn't bring back any records.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Humm... try running the query without the WHERE clause.  BTW, has the trigger been created on your test database?
dkim18Author Commented:
A copy of the database was attached to my local sql server so it has the tiggers.
I can see it from the table's trigger property.
dkim18Author Commented:
The production sql server brought back records with trigger names.
SELECT name, is_disabled FROM sys.triggers

But not from my local sql server.
Does SELECT * FROM [YourDatabase].[sys].[triggers] return any rows?
I'm not sure why that happened, but it seems the solution is to recreate the triggers on the test database.
dkim18Author Commented:
You are right. The tiggers are not there on the local test server.
I am pretty sured I've seen them but not now I don't see them any more.

The my sql server just froze and I had to restart it but I don't see why the trigger would not be there.
All I did was attached the copy of the production database to my local test sql server.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.