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 |
wided
Posting Yak Master
218 Posts |
Posted - 2013-12-12 : 06:25:00
|
HelloI just installed sql2012 and I attached a database that works well on SQL2008R2it worked well except that at the triggers, I have error messages:Here is my code(trigger)ALTER trigger [ dbo]. [ Ti_tuser ] on [ dbo]. [ Tuser ] for insert asbegin declare @ numrows int, @ int numnull , @ errno int, @ errmsg varchar (255) select @ numrows = @ @ rowcount if @ numrows = 0 return if update ( CMATRICULE ) begin select @ numnull = ( select count (*) from inserted Where CMATRICULE is null ) if @ numnull ! = @ numrows if (select count (*) TEMPLOYE from t1, t2 inserted Where t1.CMATRICULE = t2.CMATRICULE ) numrows = @ - @ numnull begin select @ errno = 30002 , @ errmsg = ' code ' TEMPLOYE " unknown. Creation of " Tuser " prohibited. " goto error end end return/ * Error handling * /error: raiserror @ errno @ errmsg rollback transactionendThe error message isMsg 102, Level 15 , State 1 ? , ti_tuser Procedure , Line 37Incorrect syntax near ' @ errno .Thank you for helping me because it tye code is everywhere in my databaseGoogle Traduction pour les entreprises :Google Kit du traducteur |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-12-12 : 10:39:13
|
For some reason it looks like spaces have been introduced into your trigger code around most of the special characters. (/ * @ [ ] ) all have extra spaces around them. First confirm that the code in your 2008 server does not have the spaces then I would try taking a backup from the 2008 server and restoring it to the 2012 server. Rather than however you did it.Be One with the OptimizerTG |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2013-12-12 : 11:04:09
|
the line / * Error handling * /is a commentI tried to restore database and not attached, it is the same problem |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-12-12 : 11:35:06
|
There are spaces introduced all over this code. Sorry I've never see this problem. I would guess it has something to do with encoding. UTF-8 vs unicodeJust to confirm please script out and post this trigger from the 2008 instance.EDIT:see what I mean (below)?ALTER trigger [ dbo]. [ Ti_tuser ] on [ dbo]. [ Tuser ] for insert asbegin declare @ numrows int, @ int numnull , @ errno int, @ errmsg varchar (255) select @ numrows = @ @ rowcount if @ numrows = 0 returnvs.ALTER trigger [dbo].[Ti_tuser] on [dbo].[Tuser] for insert asbegin declare @numrows int, @int numnull , @errno int, @errmsg varchar (255) select @numrows = @@rowcount if @numrows = 0 return Be One with the OptimizerTG |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2013-12-12 : 11:52:43
|
it is the samei found raiserror @errno @errmsgmust beraiserror(@errmsg,16,1) |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2013-12-12 : 11:53:30
|
it worksthanks TG |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-12-12 : 13:33:12
|
you're welcome. I see, so it was just scripting out the code and posting it here that introduced the extra spaces. Yeah if you used that old syntax for raiserror then you may want to search for any code that contains join hints to specify a specific index. that syntax also changed at some point.Be One with the OptimizerTG |
|
|
|
|
|
|
|