'result' possibly an SQL reserved word.

Jun 20, 2012 at 9:45 PM

I converted Survey Master to a VS2010 project. When I went to run the 2 SQL Query scripts (SurveyMaster.sql & "survey proc.sql") I ran into an issue with the latter; I kept getting the error "invalid object name 'result.'"  I'm not familiar at all with SQL scripts so I just started playing around with it and eventually ended up changing 'result' to 'myResult' (both on lines 324 & 342). After that the script would run just fine.  After both scripts ran successfully I went ahead and ran the project in VS.  When navigating to the 'Survey' action of the 'SurveyMaster' controller, the application would break at line 24 of the Index.aspx page, stating there was "invalid syntax near 'result.'" This crash occurred in DbUtil.cs inside the 'data' namespace on the method beginning at line 260: "public static IEnumerable<T> GetPage<T>(int page, int pageSize, string cs) where T : new()..."

After some more messing around I eventually noticed that inside of the previously mentioned method was an SQL CommandText containing the words 'result' again.  So in a last-ditch effort I renamed these two 'result's to 'myResult' (lines 269 & 273), ran the application again, and everything runs smoothly now =)

So in summation, if you find the word result inside any SQL script, rename it to a less-likely-to-be-a-reserved-word...word =)

Coordinator
Jun 20, 2012 at 9:51 PM

that's strange, I didn't had this kind of problems (obviously, otherwise I wouldn't released it this way), what DB are you using ?

Jun 20, 2012 at 9:55 PM
Edited Jun 20, 2012 at 9:56 PM

That's probably another important piece of the puzzle.  I'm using SQL Server 2012 (64-bit).  I Googled "SQL reserved words" and found this link: http://msdn.microsoft.com/en-us/library/aa238507(v=sql.80).aspx

The last table titled "Future keywords," it mentions "The following keywords could be reserved in future releases of SQL Server as new features are implemented. Consider avoiding the use of these words as identifiers," and under that table you'll find "RESULT."

Maybe it's new in SQL Server 2012?

Coordinator
Jun 20, 2012 at 10:07 PM

should be, that's the only logical explanation why you had this problem