Syntax error in TextHeader of Stored Procedure
Rather annoyingly today, I had this error message pop up when trying to view a Stored Procedure.
The error is generated from SMO (). I knew that the stored procedure hadn’t been updated in a long time and my first thought was that there was some form of corruption.
I opened up a new SQL Server Management Studio application with no joy. I tried from the physical server; Same error. The only thing that I could think of that had changed was that I was now using SQL Server 2008 R2 Tools, so I tested with the SQL Server 2005 Tools and voila, I could now view the Stored Procedure. But why….?
I could not see why, so after a bit of digging around, I discovered that SMO get’s itself in a mess if you have some nested comments or no seperation of comments. In my Stored Procedure I had something like /* Some Silly Comment *//* Another Silly Comment */
As soon as I broke that up into two seperate lines of code, it worked in SQL Server 2008 R2 Management Studio!