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

  • SEARCH
  • Home
  • 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 1042851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:34:24+00:00 2026-05-16T15:34:24+00:00

I wanna change dynamicaly name of table in sql query. For example I have

  • 0

I wanna change dynamicaly name of table in sql query. For example I have next stored procedure:

CREATE PROCEDURE NewProc(IN tableName varchar(64),IN message text)
BEGIN
    INSERT INTO tableName VALUES (message);
END;

I need to change tableName in runtime, Can I to do it or not?
Thanks.

  • 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-16T15:34:25+00:00Added an answer on May 16, 2026 at 3:34 pm

    You must use dynamic SQL to prepare and execute an SQL string, to achieve what you describe.

    Dynamic table names (or column names, or SQL keywords, etc.) must be interpolated into the SQL string before prepare. You can’t use query parameters for these dynamic elements.

    Be careful to avoid SQL injection vulnerabilities when you interpolate the table name into your SQL query. For example, you should check that the table name exists by looking it up in the information schema.

    I agree with the comment from @OMG Ponies — it’s a code smell that you have multiple tables with identical structure such that you want to do the exact same insert to the exact same column. Code smells aren’t a guarantee that you’ve got a bad design, but it’s worth considering.

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

Sidebar

Related Questions

I have this string @[123:peterwateber] hello! good day! I wanna change it to <a
I have my own database (SQL Server 2008 RQ) and i have a table
I have images as my website menu button, and I wanna change the image
In string.xml, <?xml version=1.0 encoding=utf-8?> <resources> <string name=app_name>nameofmyapp</string> </resources> I wanna change the text
i have a label and i wanna change it's location corresponding to mouse position,
I have different views on my activity. I wanna change my cursor style when
is it possible to change type of whole array for example, I have: object[]
i have a little problem with page scrolling... I wanna to change some css
I wanna change APN settings in a phone. Looked the api and there is
i use Sherlock Actionbar 1, i wanna change Home Button BG when i press

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.