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 96631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:51:00+00:00 2026-05-10T23:51:00+00:00

As the topic suggests I wish to be able to pass table names as

  • 0

As the topic suggests I wish to be able to pass table names as parameters using .NET (doesn’t matter which language really) and SQL Server.

I know how to do this for values, e.g. command.Parameters.AddWithValue('whatever', whatever) using @whatever in the query to denote the parameter. The thing is I am in a situation where I wish to be able to do this with other parts of the query such as column and table names.

This is not an ideal situation but it’s one I have to use, it’s not really prone to SQL injection as only someone using the code can set these table names and not the end-user. It is messy however.

So, is what I am asking possible?

EDIT: To make the point about SQL injection clear, the table names are only passed in by source code, depending on the situation. It is the developer who specifies this. The developer will have access to the database layer anyway, so the reason I am asking is not so much for security but just to make the code cleaner.

  • 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. 2026-05-10T23:51:00+00:00Added an answer on May 10, 2026 at 11:51 pm

    I don’t think I’ve ever seen this capability in any SQL dialect I’ve seen, but it’s not an area of expertise.

    I would suggest restricting the characters to A-Z, a-z, 0-9, ‘.’, ‘_’ and ‘ ‘ – and then use whatever the appropriate bracketing is for the database (e.g. [] for SQL Server, I believe) to wrap round the whole thing. Then just place it directly in the SQL.

    It’s not entirely clear what you meant about it not being a SQL injection risk – do you mean the names will be in source code and only in source code? If so, I agree that makes things better. You may not even need to do the bracketing automatically, if you trust your developers not to be cretins (deliberately or not).

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

Sidebar

Related Questions

I've read many answers here about this topic, but everyone suggests the BCP ||
The topic says it all. Using Compact Framework C# I'm tiling (order/sequence is important)
As the topic suggests I have some problems with PropertyInfo.SetValue. To get to the
As the topic suggests, I'm trying to calculate a ramped visibility map out of
As the topic suggests I am attempting to take integers (in tuples) from one
As the topic suggests I have a server and some clients. The server accepts
I wish to create something similar for my app like: http://www.facebook.com/pages/English-Language/106059522759137 http://www.freebase.com/view/en/barack_obama I could
topic.php $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $query = mysql_query(SELECT * FROM topics
Topic is self explanatory. I found xaml code to do it for an Expander,
This topic has been covered on this forums, but I haven't found a working

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.