Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can you add comments to an access sql statement? 2

Status
Not open for further replies.

danhauer

Programmer
Apr 17, 2001
39
US
I have a series of queries and I just want to run them one at a time without retyping. I have an Oracle script that I modified with a bunch of statements that I could copy and paste 30 times, but I'm looking for a way to place a comment so I can just uncomment them one at a time and run them... if that makes sense.

Any help would be appreciated!

Thanks,

Danhauer
 
danhauer,

you mean in a sequence? Then just use a macro with the runquery property. If you mean manually with changes, then use the like [something] criteria and Access will prompt you.

LJ
 
Hey LJ... thanks for answering so fast! I tried the run sql in macro and the text is too long... here is an example of what I am trying to do:

INSERT INTO T_SC_CRITERIA ( SUPPLIER_TYPE, CRITERIA_ID, MEASURE, CATEGORY, MIN_MEASURE, MAX_MEASURE, WEIGHT, POINTS, ENTITY, CHANGE_DATE, RACF_ID, ACTIVE_FLAG ) VALUES ( NULL, 4202, 'FINANCIAL STRESS PERCENTILE', 'INTERNAL PROCESSES', 1, 41, NULL, 2, 'ALL', NULL, NULL, 'Y');

INSERT INTO T_SC_CRITERIA ( SUPPLIER_TYPE, CRITERIA_ID, MEASURE, CATEGORY, MIN_MEASURE, MAX_MEASURE, WEIGHT, POINTS, ENTITY, CHANGE_DATE, RACF_ID, ACTIVE_FLAG ) VALUES ( NULL, 4203, 'FINANCIAL STRESS PERCENTILE', 'INTERNAL PROCESSES', 0, 0, NULL, 0, 'ALL', NULL, NULL, 'Y');

I have about 30 of these types of statements for about six different tables... so I am copying and pasting and running the queries.. (tedious)

If I could put all the statements in one query and keep commenting out the ones below the one I'm trying to run, it would go a lot faster.

 
I would just create the query, paste in the SQL (change the view to SQL) and then run the query from a macro.

I could be misunderstanding you, so I hope you don't take offense to what I listed.

Good Luck.
 
Oh hey, no offense - no way! I take all the help I can get, and sometimes the obvious things are things I overlook! I appreciate your comments!

I tried pasting the whole script into SQL and saving it, but it poops out after the first statement ("characters found at end of SQL statement") and won't let me save it.

I just thought there might be a way to add comments in an SQL statement, like if I wanted to say something like:

INSERT INTO T_SC_CRITERIA ( SUPPLIER_TYPE, CRITERIA_ID, MEASURE, CATEGORY, MIN_MEASURE, MAX_MEASURE, WEIGHT, POINTS, ENTITY, CHANGE_DATE, RACF_ID, ACTIVE_FLAG ) VALUES ( NULL, 4202, 'FINANCIAL STRESS PERCENTILE', 'INTERNAL PROCESSES', 1, 41, NULL, 2, 'ALL', NULL, NULL, 'Y');

'this is my sql statement comments

(where really here is where I would block out the next sql statement, then remove the comment marks to activate the next one)

dang, it would just be nice to put the whole script into one statement, ya know?

Thanks again for your help!
 
Put each individual SQL statement in a separate RUNSQL command in a macro. Turn on the Conditions column of the macro and put a 0 to "comment" out that RUNSQL command.

You can also save the individual SQL statements as queries and run them with the OPENQUERY command in the macro instead.

John
 
Good call John! That's where I wanted to head but never turned the corner. Thanks for jumping in to set the record straight!
LJ
 
You can also put those 30 sets of values for new rows into another table and then use an append query to add one or more rows at a time to the T_SC_Criteria. In this "from" table, add a Yes/No field and check it for the rows to append. You can append all checked rows at one time then.

John
 
Thanks everyone! I ended up copying and pasting each one and running it from the query window... only because I was spending so much time trying to find an easier way that I could just do it and get it over with. But, I have more to do and will definitely explore the great suggestions.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top