Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Macro substituion
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00840471
Message ID:
00889612
Views:
20
>>How would I replicate useing a macro substitution inside a stored procedure that I have created? What I want to create is a standard select expression with the various parts decided by what paramters are being passed to the procedure. The standard statement in VFP would look like this:
>>
>> select * from &fromclause where &whereclause order by &orderclause
>>
>>How could I mimick this in SQL server?
>>
>Hi Kelly,
>
>You can build SQL statement as a local string variable and than run it using EXECUTE command or sp_executesq system sproc. For example,
DECLARE @Sql varchar(4000)
>SET @Sql = 'SELECT fld1 FROM [' +  @lcTableName + ']'
>EXECUTE (@Sql)
How are you able to use '[' and ']' w/o getting an error?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform