Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there any equivalent of indirection (macro) in T-SQL?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01191074
Message ID:
01191084
Vues:
17
>Look at sp_executesql in TSQL. It has limits and can be a pain, but sometimes it is pretty handy.

Ahh. I read about it now in BOL.
So something like this should work then:
-- passed param: @ColumnName2Get
DECLARE @SQLString NVARCHAR(500)

SET @SQLString = N'SELECT ' + @ColumnName2Get + CHAR(13)
SET @SQLString = @SQLString + 'WHERE condition_here'

EXEC sp_executesql @SQLString
Will rewrite and try it now. Thx.


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform