Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
I have a table in SQL in which I inserted my other table names. There is a Table names column. So, is it possible (programmatically inside SQL) getting the table names from this column and use them in stored procedure as table name? How? inside SQL. thanks
Posted
Updated 12-Mar-13 12:57pm
v2

1 solution

It's uncommon but it's possible.

The magic beans you are looking for is called a prepared statement[^].

You could query your table-table for a table name and assign that to a variable and then construct the SQL for the prepared statement on-the-fly.

See The Curse and Blessing of Dynamic SQL[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Mar-13 19:25pm    
5ed.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900