SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Remove SQL Comments

By Jordan Ryder,

This script removes comments and handles complex nesting. A sql string can be passed in and the function will return the code but with comments removed. 

Example of complex scenarios that this function correctly handles:

-- /* multi-line ignored
--*/ this text is not a comment

Total article views: 592 | Views in the last 30 days: 2
Related Articles

Better Comments

Is there a best way to comment code? Or maybe just different styles. Steve Jones asks what you think...


Comments in BIDS SQL

Comments in SSRS SQL


Invisible Comments

I ran into a dilemma when I was told that I should not allow potential competitors to view my JavaSc...


Database Commenting Guideline

Commenting seems to be the bane of every programmer, database or otherwise. Sachin Dedhiya brings us...


The Worst Comments

Comments in code can be tricky, but certainly some are better than others. What are your bad example...