Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2002
    Posts
    2

    Question Unanswered: use SQL to generate SQL statements

    Hi there, I have two questions about Access Sql.

    1.Can we use SQL to generate SQL statements in Access2000?

    I put this below sql statments in a query and ran it and got errors:
    SELECT 'SELECT COUNT(*) FROM '||TABLE_NAME||';' FROM MYTABLES;

    It seems that Access SQL doesn't accept '||'. Does access sql support the the concatenation.

    2. Can we run multiple sql statments in a query.

    If I run 'SELECT COUNT(*) FROM TableA;' it works fine. But If I run more than one statements in a query like below, I got errors.

    SELECT COUNT(*) FROM TableA;
    SELECT COUNT(*) FROM TableB;

    Thank you very much in advance !

    -James

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    1. use & or + instead of || (i can't remember which)

    2. no, just one at a time -- however, you could run this:

    SELECT 'Table A', COUNT(*) FROM TableA
    union all
    SELECT 'Table B', COUNT(*) FROM TableB
    union all
    SELECT 'Table C', COUNT(*) FROM TableC

    up to maybe 16 of them? 255 of them?

    rudy
    http://rudy.ca/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •