Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a project and that project need to make table name dynamic, means i want to pass table name as a parameter in my stored procedure from front end. So that i can communicate any table with same table structure....


Thanks in advance..........


pls help....
Posted
Comments
Christian Graus 26-Dec-13 5:23am    
As the first answerer told you, this is a stupid thing to do. Your schema should NOT be so fluid that you need dynamic table names. You should rethink your schema to lose this requirement

You can use dynamic query approach. You practically build your query as string and execute it inside the procedure, so you can use your table name as parameter. Look here: Building Dynamic SQL In a Stored Procedure[^]. But it rarely wise to do so. You will end up with an unsustainable application. You better put your DAL and BL "near" the DBMS, and solve this need on a higher level.
 
Share this answer
 
pass table name as a string and in store procedure write a query statement in varchar and finally execute using exec method to that statement.
 
Share this answer
 

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