-
Select from a table_var. How ??
Hi to all,
can someone tell me how i can do this work?
declare @cTableName varchar(30)
set @cTableName = 'clients'
select * from @cTableName
this gives me an : Line 4: Incorrect syntax near '@cTableName'.
The reason i want to this is that i want to pass the tablename (created
somewhere else)
in a stored procedure and do some work there.
I know that i can constract a string and use exec to execute it but for
several reasons
this is not an option for me on this.
Thanks a lot,
have a great weekend!
anthonyb
-
Re: Select from a table_var. How ??
checkout: http://www.mssqlserver.com/faq/devel...dynamicsql.asp
You will need to explain: "I know that i can constract a string and use exec
to execute it but for several reasons this is not an option for me on this"
--
HTH,
David Satz
Principal Software Engineer
Hyperion Solutions
->Using SQL Server 7.0 SP3/6.5 SP5a/Cold Fusion 4.5.1 SP2/VSS
(Please reply to group only - emails answered rarely)
-----------------------------------------------------------------
"Anthony Boudouvas" <mediatel@ath.forthnet.gr (anthonyb)> wrote in message
news:3aa8f492@news.devx.com...
> Hi to all,
>
> can someone tell me how i can do this work?
>
> declare @cTableName varchar(30)
>
> set @cTableName = 'clients'
> select * from @cTableName
>
>
> this gives me an : Line 4: Incorrect syntax near '@cTableName'.
>
>
> The reason i want to this is that i want to pass the tablename (created
> somewhere else)
> in a stored procedure and do some work there.
> I know that i can constract a string and use exec to execute it but for
> several reasons
> this is not an option for me on this.
>
> Thanks a lot,
>
> have a great weekend!
>
> anthonyb
>
>
-
Re: Select from a table_var. How ??
> You will need to explain: "I know that i can constract a string and use
exec
> to execute it but for several reasons this is not an option for me on
this"
I will ask it in another way: Can u help me with that question by providing
another solution than "execute" ??
It's just that!
anthonyb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks