Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
SQL: Passing A FIELD NAME As A Parameter
Hi All:
I'm trying to create a Stored Procedure where I can send parameters
of which one is a FIELD NAME of a table. Then I'd like to update
that FIELD with another parameter I'm sending (along with the FIELD
NAME) parameter. The code I tried looks like this, but it does not
work.
CREATE PROCEDURE Test_SP
@RoomNo smallint, @Field_Name char, @Assign_This char
AS
UPDATE MyTable
SET @Field_Name = @Assign_This
WHERE ROOM = @RoomNo
@Field_Name is one of the FIELD NAMES in MyTable.
I'm not getting an error message, in fact, the Query Analyzer tells
me that 1 row was affected. When I check the table, no sign of an
UPDATE - nothing's changed.
Any advice would be appreciated. TIA
MAL
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement