Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use variable tablenames in SP
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
How to use variable tablenames in SP
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Desktop
Divers
Thread ID:
01519190
Message ID:
01519190
Vues:
70
Hello,

I am writing a stored procedure where the tablename in a select statement can be variable.

In VFP I probably would use name substitution:
lcMyTable = "Users"
lcUser = "Christian"
SELECT * FROM (lcMyTable) WHERE Username = lcUser
In SQL that approach gives me problems, it either says "Must declare the table variable" or if I used a dynamic SQL Must delcare the scalar variable". I guess there is a simple approach but I just can't figure out what is the right one.
Christian Isberner
Software Consultant
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform