Jun 8, 2001 #1 kenjoswe Technical User Sep 19, 2000 327 SE Hi all, Is it possible to substitute a fieldname in a stored procedure with a parameter something like: @Field varchar(50) select * from Table1 where @Field= 'criteria' /Kent J.
Hi all, Is it possible to substitute a fieldname in a stored procedure with a parameter something like: @Field varchar(50) select * from Table1 where @Field= 'criteria' /Kent J.
Jun 8, 2001 1 #2 cdukes Programmer Aug 6, 1999 286 FR Yes, But you will have to exec the statement: DECLARE @Field varchar(50) DECLARE @Str VARCHAR(255) SELECT @Field = 'MyField' SELECT @Str = "SELECT * FROM Table WHERE ' + @Field + ' = '''criteria''' EXEC (@str) I think this is what you mean, Chris Dukes Upvote 0 Downvote
Yes, But you will have to exec the statement: DECLARE @Field varchar(50) DECLARE @Str VARCHAR(255) SELECT @Field = 'MyField' SELECT @Str = "SELECT * FROM Table WHERE ' + @Field + ' = '''criteria''' EXEC (@str) I think this is what you mean, Chris Dukes
Jun 8, 2001 Thread starter #3 kenjoswe Technical User Sep 19, 2000 327 SE Thanks! That really helped me! /Kent J. Upvote 0 Downvote