Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variable Scope
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Miscellaneous
Thread ID:
00663609
Message ID:
00663615
Views:
21
You can run select like this w/o EXEC
select * from tablename where ckeyfieldname = @cwhere
If it just an example, than
set @csql = 'select * from tablename where ckeyfieldname = ''' + @cwhere +''''
Note, that single quote in the string literal has to be doubled.


>I know there has to be a way to do this... how do I make the following work?
>
>
>declare @cwhere as varchar(1000)
>declare @csql as varchar(1000)
>
>set @cwhere = 'XXXXXXXX'
>
>set @csql = 'select * from tablename where ckeyfieldname = @cwhere'
>exec (@csql)
>
>
>I am losing me @cwhere variable when I evaluate the @csql string. BTW, this is a simple example of what I am trying to do only for example.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform