Click here to Skip to main content
Click here to Skip to main content

Remove comment in SQL

, 12 Feb 2003
Rate this:
Please Sign up or sign in to vote.
Remove comment in SQL to make it easy to execute with MS Access.

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

Share

About the Author

colison

China China
No Biography provided

Comments and Discussions

 
Generalthe best way to "remove" SQL comment PinsussAnonymous13-Feb-03 7:58 
GeneralRe: the best way to "remove" SQL comment Pinmembercolison13-Feb-03 13:50 
GeneralRe: the best way to "remove" SQL comment PinsussAnonymous20-Feb-03 7:52 
GeneralRe: the best way to "remove" SQL comment PinmemberTerry Denham14-Feb-03 3:27 

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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 13 Feb 2003
Article Copyright 2003 by colison
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid