🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.ms-sqlserver
Article #23

[SQL Server] parameterized FROM clause in Stored Procedure

#23
From: Pol
Date: Sat, 17 May 1997 00:00
29 lines
1367 bytes
THE SITUATION
-------------
I have a small-database that I'm upsizing to SQL Server.
One of its stored procedures takes a parameter to tell it what file to
SELECT from.

THE PROBLEM
-----------
I can't define a stored procedure in SQL Server that takes a parameter
in the FROM clause.  For example:

CREATE PROCEDURE sp_GetRecord (@pcTableName varchar(20), @pnID
Numeric(15))
WITH RECOMPILE
AS
SELECT * FROM @pcTableName 
WHERE VM_ID = @pnID

THE QUESTION
------------
Is there any way to include a Stored Procedure parameter in the FROM
clause of a SELECT statement in the Stored Procedure?

Thanx.

If you could also reply by Email, that'd be great.

pol@ix.netcom.com
Technical Details
Message-ID: <337def13.233528015@nntp.ix.netcom.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11301e,ef88ae280986e9b8,start
X-Google-Attributes: gid11301e,public
X-Google-Thread: 104de1,ef88ae280986e9b8,start
X-Google-Attributes: gid104de1,public
X-Google-Thread: f6611,ef88ae280986e9b8,start
X-Google-Attributes: gidf6611,public
From: pol@ix.netcom.com (Pol)
Subject: [SQL Server] parameterized FROM clause in Stored Procedure
Date: 1997/05/17
Message-ID: <337def13.233528015@nntp.ix.netcom.com>
X-Deja-AN: 242114438
Organization: Netcom
X-NETCOM-Date: Sat May 17 10:53:51 AM PDT 1997
Newsgroups: comp.databases.ms-sqlserver,microsoft.public.sqlserver.programming,bit.databases.mssql-l