Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

insert into using a select/union

insert into using a select/union

insert into using a select/union

I am trying to populate a temp table from a list of values I get back from a Java method call. I'm trying to do a batch insert, but cannot seem to find the right syntax. I tried

SELECT 'constant1' n from table
SELECT 'constant2' n from table

The syntax works, but I am inevitably going to exceed the maximum statement length and I cannot use the same clasue again since the temp table already exists. I tried the followig, but I keep getting a syntax error:

SELECT 'constant1' from table
SELECT 'constant2' from table;

Any ideas? I really do not want to have to generate a separate insert statement for every value in my list.

Also, my table is guaranteed to only ever have one row so I just get back the singlular constant value. Is there a better way to force only one row instead of having to rely on the table only having one row? FIRST 1 is not supported within an INSERT or INTO.

RE: insert into using a select/union


i tried both of your suggestions and never get an error.

Are you sure you do not suppress any details?

If you select a constant you will have to provide a pseudo-column-name, which i guess should be the "n" in your statement.

please check if you omitted something.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close