Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
njahnavi
Starting Member
4 Posts |
Posted - 2009-03-12 : 14:27:27
|
| HI I am new to sql server triggers...when i try to create a trigger i am gettign this errorMsg 2103, Level 15, State 1, Procedure trig_addAuthor2, Line 17Cannot create trigger 'testtable.trig_addAuthor2' because its schema is different from the schema of the target table or view.i am just trying to create a simple trigger likeCREATE TRIGGER testtable.trig_addAuthor2 ON dbo.testtableFOR INSERT AS-- Get the first and last name of new author DECLARE @test VARCHAR(100) SELECT @test = (SELECT testcolumn FROM Inserted)-- Print the name of the new author PRINT 'new data "' + @test + '" added.' |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-03-12 : 14:43:18
|
| I'm going to assume that the table schema is dbo and not testtable. You should try replacing testtable.trig_addAuthor2 with dbo.trig_addAuthor2.Mike"oh, that monkey is going to pay" |
 |
|
|
guptam
Posting Yak Master
161 Posts |
Posted - 2009-03-13 : 00:57:07
|
| When creating trigger the syntax is:CREATE TRIGGER triggerName ON TableNamenotCREATE TRIGGER tablename.triggername ..:)Thanks.-- Mohit K. GuptaB.Sc. CS, Minor JapaneseMCITP: Database AdministratorMCTS: SQL Server 2005http://sqllearnings.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-13 : 13:49:30
|
| whats the default schema for user running this code? |
 |
|
|
njahnavi
Starting Member
4 Posts |
Posted - 2009-03-16 : 12:30:23
|
| Thanks for the reply guys...I have tried and it worked. |
 |
|
|
|
|
|