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:
01275772
Vues:
9
>An alternative to using the sp_executesql:
>
>This assumes @Agedstatement is something like '> 30', @Clearstatement is ' AND IsCleared = 1', etc. The parantheses are important.
>
>
>EXEC ('SELECT * FROM #Final WHERE Aged ' + @AgedStatement + ' ' + @ClearStatement + ' ' + @IsHeldStatement +
>	' Order by RecordType, SUBSTRING(Account, 12, 8), Account, CFI, Aged, SWDN')
>
>
>
>

Is it possible to declare a variable with a variable type?

Say,
declare @cType varchar(20)

Set @cType 'varchar(5)'

declare @myNewVar @cType  -- How can I do that?
Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform