Click here to Skip to main content
Licence 
First Posted 12 Feb 2003
Views 51,769
Bookmarked 16 times

Remove comment in SQL

By | 12 Feb 2003 | Article
Remove comment in SQL to make it easy to execute with MS Access.
 
Part of The SQL Zone sponsored by
See Also

Introduction

Your can write SQL which reads good, like this:

-- What the sql (et. stored procedure )writen for
-- and/or how to use it
/* Or block comment like this
   What the sql (et. stored procedure )writen for
   and/or how to use it
*/
create table tablename (
    fieldname text(255), -- comment for field 
    content text(255));

Comments in SQL statements sent through ADO will sometimes error out in ADO when ADO tries to parse it. By stripping out the comments, you have both documented SQL code and you don't get any errors when you try to use the commented code within your ADO application. Then use these SQL saved in files directly!

How to use it?

Declare the function in any .h file of your project:

int ClearSQLComment(LPCTSTR lpSQL,CString &rString);

and use it:

CString strText,strSQL;
//Read all text from file to a CString object ,write it yourselft
LoadTextFromFile(lpFileName,&strText);
ClearSQLComment(strText,strSQL);
//...Execute SQL 
Connect.Execute(strSQL,&affected,adCmdText);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

colison



China China

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalthe best way to "remove" SQL comment PinsussAnonymous7:58 13 Feb '03  
GeneralRe: the best way to "remove" SQL comment Pinmembercolison13:50 13 Feb '03  
GeneralRe: the best way to "remove" SQL comment PinsussAnonymous7:52 20 Feb '03  
GeneralRe: the best way to "remove" SQL comment PinPopularmemberTerry Denham3:27 14 Feb '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 13 Feb 2003
Article Copyright 2003 by colison
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid