Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Does macro substitution exist in SQL?

Author  Topic 

frank2
Starting Member

35 Posts

Posted - 2005-08-23 : 10:48:26
I am a Visual FoxPro user moving over to SQL 2000. I have some SELECTs that I run against several tables. What I do is pass the procedure the name of the table and use that parameter in the SELECT statement. This works because VFP allows macro substitution.

For example:

SELECT * from DataDict

Instead of using the literal table name I can load the name into a variable

x = "DataDict"

Then using macro substitution use the variable in place of the literal name.

SELECT * from (x)
or
SELECT * from &x

In VFP macro substitution can be used to define the result field list or any other clause in a SELECT.

Is a similar capability available in SQL? If so how do I do it and where can I find documentation?

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-08-23 : 10:49:18
dynamic sql....search here.
Go to Top of Page
   

- Advertisement -