Click here to Skip to main content
12,076,206 members (44,507 online)
Click here to Skip to main content
Add your own
alternative version

Stats

58.1K views
377 downloads
16 bookmarked
Posted

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

You may also be interested in...

Comments and Discussions

 
Generalthe best way to "remove" SQL comment Pin
Anonymous13-Feb-03 8:58
sussAnonymous13-Feb-03 8:58 
GeneralRe: the best way to "remove" SQL comment Pin
colison13-Feb-03 14:50
membercolison13-Feb-03 14:50 
GeneralRe: the best way to "remove" SQL comment Pin
Anonymous20-Feb-03 8:52
sussAnonymous20-Feb-03 8:52 
GeneralRe: the best way to "remove" SQL comment Pin
Terry Denham14-Feb-03 4:27
memberTerry Denham14-Feb-03 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.160208.1 | Last Updated 13 Feb 2003
Article Copyright 2003 by colison
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid