Click here to Skip to main content
11,579,093 members (64,457 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# SQL StoredProcedures
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 12-Mar-13 12:42pm
Edited 12-Mar-13 12:57pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]
Sergey Alexandrovich Kryukov at 12-Mar-13 19:25pm

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

  Print Answers RSS
0 Peter Leow 115
1 Frankie-C 115
2 OriginalGriff 113
3 Afzaal Ahmad Zeeshan 85
4 Richard MacCutchan 85
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 12 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100