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 |
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2009-01-20 : 10:27:11
|
Hello everyoneCreate proc dbo.testprocasbegindeclare @i varchar(10)Set Set Set set set @i = 'a'select * from sysobjects where type = 'u'end Notice the multiple "Set"s in the code. In SQL 2000 SP4, the code runs fine. I can compile the proc and execute it too. The Set statement is completely ignored. In 2005 however, I get an error as expected even when parsing the script. I thought the syntax is checked at compile time? Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-01-20 : 11:34:29
|
Do you think the "weird" part is that this works in 2000 or that 2005 does a lot more checking during parsing (preventing compilation)? Cause I think it's weird that this doesn't blowup in 2000 :) btw my little test showed that the statement isn't ignored just the extra "set"s are ignored. My variable value was still set by the statement.Be One with the OptimizerTG |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2009-01-20 : 11:54:30
|
The weird part is 2000 happily ignores the syntax error. The code even compiles and executes without errors, which is ridiculous.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2009-01-20 : 12:10:04
|
For that case, it even accepts SETor SET SELECTwithout any complaint. One reason could be that SET is not only used for variable assignment, but also for setting various options. Hence, SQL Server 2000 might be bit lenient for checking SET syntax.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
|
|
|