I created a script with SQL Server 2012 that sets a variable's which should be okay because I saw it in the MSDN. The compiler didn't like it and I couldn't understand why since it was in the MSDN and I was using SS 2012. The script ran fine once the assignment was commented out. The database's compatibility level is set to SS 2005 which I suspect is why the compiler didn't like it.
My questions are about compatibility levels. It seems that the compatibility level for this was prohibiting the compiler from liking the assignment since it was set to an older version of SS. Does this sound like an accurate conclusion on the possible results of using an older compatibility level with newer syntax? I assume that any code used for a certain compatibility level must only use syntax that was available at the time that version was released. Is this correct?
This is what was used:
DECLARE @GLTRdeletes AS INT = 0