🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.ms-sqlserver
2 messages
2 total messages Started by Brent Eubanks Thu, 06 Mar 1997 00:00
Need help using parameters in FROM clause
#56
Author: Brent Eubanks
Date: Thu, 06 Mar 1997 00:00
32 lines
1245 bytes
In SQL Server 6.5, I'm trying to write a stored procedure that takes a
parameter and uses it in the FROM clause of a SELECT statement.
ie:

create proc test @office varchar(10) as

select ...
from @office
where...



When I try to run this, ISQLW screams and makes reference to the line
with the FROM
clause.  Am I trying to do something that is simply not permitted, or
is something
else going on?  I couldn't find any specific mention of _not_ being
able to use 
variables/parameters in a FROM clause.

I would appreciate it if replies were cc'd to my email account:
brent@ugcs.caltech.edu

Thanks

Brent

--

--
Brent Eubanks					    brent@ugcs.caltech.edu
Re: Need help using parameters in FROM clause
#58
Author: Chris McKulka
Date: Thu, 06 Mar 1997 00:00
19 lines
931 bytes
Try:

declare @sqlStmt varchar(255)
select @sqlStmt='Select * from ' + @office
exec (@sqlStmt)


brent@ugcs.caltech.edu (Brent Eubanks) wrote:

>In SQL Server 6.5, I'm trying to write a stored procedure that takes a
>parameter and uses it in the FROM clause of a SELECT statement.
>ie:
>
>create proc test @office varchar(10) as
>
>select ...
>from @office
>where...
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads