Article View: comp.databases.ms-sqlserver
Article #24Re: [SQL Server] parameterized FROM clause in Stored Procedure
From: Bob Pfeiff
Date: Sat, 17 May 1997 00:00
Date: Sat, 17 May 1997 00:00
21 lines
1090 bytes
1090 bytes
You need to build the sql statement in the procedure then execute it: create proc param @table varchar(30), @where varchar(50) as declare @sql varchar(50) select @sql = 'select * from ' + @table + ' ' + @where exec (@sql) You can then run the SP like this: param authors, 'where au_lname = "green"' Bob Pfeiff Spectrum Technology Group, Inc. bobp@spectrumtech.com
Technical Details
Message-ID:
<01bc6344$78872520$1c0a10ac@pfeiffhome>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: 11301e,ef88ae280986e9b8 X-Google-Attributes: gid11301e,public X-Google-Thread: 104de1,ef88ae280986e9b8 X-Google-Attributes: gid104de1,public From: "Bob Pfeiff" <bobp@spectrumtech.com> Subject: Re: [SQL Server] parameterized FROM clause in Stored Procedure Date: 1997/05/17 Message-ID: <01bc6344$78872520$1c0a10ac@pfeiffhome> X-Deja-AN: 242183710 References: <337def13.233528015@nntp.ix.netcom.com> Organization: Spectrum Technology Group, Inc. Newsgroups: comp.databases.ms-sqlserver,microsoft.public.sqlserver.programming,bit.databases.mssql-l