Article View: comp.databases.ms-sqlserver
Article #25Re: [SQL Server] parameterized FROM clause in Stored Procedure
From: finexprt
Date: Sun, 18 May 1997 00:00
Date: Sun, 18 May 1997 00:00
38 lines
1635 bytes
1635 bytes
On Sat, 17 May 1997, Pol wrote: > 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 declare @sql varchar(255) > select @sql="SELECT * FROM "+@pcTableName+ > "WHERE VM_ID = "+convert(varchar(30),@pnID) exec @sql > > 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:
<Pine.BSF.3.95q.970518145712.5578A-100000@sivka.carrier.kiev.ua>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<337def13.233528015@nntp.ix.netcom.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6611,ef88ae280986e9b8 X-Google-Attributes: gidf6611,public X-Google-Thread: 104de1,ef88ae280986e9b8 X-Google-Attributes: gid104de1,public X-Google-Thread: 11301e,ef88ae280986e9b8 X-Google-Attributes: gid11301e,public From: <finexprt@sivka.carrier.kiev.ua> Subject: Re: [SQL Server] parameterized FROM clause in Stored Procedure Date: 1997/05/18 Message-ID: <Pine.BSF.3.95q.970518145712.5578A-100000@sivka.carrier.kiev.ua> X-Deja-AN: 242261410 Distribution: world References: <337def13.233528015@nntp.ix.netcom.com> To: Pol <pol@ix.netcom.com> Organization: Lucky Net Ltd. Newsgroups: comp.databases.ms-sqlserver,microsoft.public.sqlserver.programming,bit.databases.mssql-l