Chris,
You need to build your SQL statement dynamically and then execute it.
Pretty straight forward.
Here is an example:
/* =============================== */
Create Procedure test
@TableName VarChar(50),
@CoumnName VarChar(50)
AS
DECLARE @SQL_Statement VarChar(255)
SELECT @SQL_Statement = 'SELECT ' + @CoumnName + 'FROM ' + @TableName
EXEC(@SQL_Statement)
/* =============================== */
-----Original Message-----
From: Chris Lott [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 24, 2000 7:06 PM
To: CF-TALK
Subject: Variable in stored procedures
Is there a way to use tsql variables as tablenames and columnames in stored
procedures using SQL Server 7? i.e.:
create procedure test
@tablename nvarchar(255),
@columname nvarchar(255)
as
select @columnname from @tablename
(which doesn't work) etc?
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.