Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there any equivalent of indirection (macro) in T-SQL?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01191074
Message ID:
01275772
Views:
10
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform