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: 556 | Views in the last 30 days: 14
 
Related Articles
FORUM

Comments in BIDS SQL

Comments in SSRS SQL

ARTICLE

Invisible Comments

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

ARTICLE

Database Commenting Guideline

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

ARTICLE

The Worst Comments

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

BLOG

Commenting TSQL Scripts

If you have ever searched for “commenting in TSQL” scripts, I am sure that you’ve found hundreds or ...

Tags
comment    
function    
sql    
 
Contribute