Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:32:29+00:00 2026-05-24T01:32:29+00:00

How do I execute an SQL string statement in DB2? I’m using IBM Data

  • 0

How do I execute an SQL string statement in DB2? I’m using IBM Data Studio.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:32:31+00:00Added an answer on May 24, 2026 at 1:32 am

    Do you mean executing a dynamic SQL string? Something like:

    DECLARE stmt VARCHAR(1000);
    DECLARE my_table VARCHAR(50);
    SET my_table = 'DEPT_'||deptNumber;
    SET stmt = 'SELECT * FROM '||my_table;
    PREPARE s1 FROM stmt;
    EXECUTE s1;
    

    You can only do that in a stored proc though. One defined as CREATE PROCEDURE GetDeptInfo (deptNumber VARCHAR(5)) for this example. Read about EXECUTE and PREPARE in the db2 docs http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using sp_executesql to execute a T-SQL statement with a dynamic table name.
Is there a way to get the raw SQL string executed when calling PDOStatement::execute()
I am running an Execute SQL Task statement in my SSIS package. The Execute
I have an Execute SQL task (SQL 2008) where I'm using two SSIS variables
When I execute a sql statement like Select ..., I can only see ...100%
If I have a valid SQL string; is there anyway I can execute it
I'm trying to execute an sql statement in vb.net to an Access database, I
I am trying to run an mysql sql statement using the code below; public
I am trying to execute the following SQL query using MS SQL Server Management
I want to execute multiple statements from my data access layer using C# dan

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.