Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UPDATE variable number of fields
Message
From
07/04/2000 14:44:10
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
UPDATE variable number of fields
Miscellaneous
Thread ID:
00357040
Message ID:
00357040
Views:
37
Hi all!

I have a stored proc that looks something like this:
CREATE PROCEDURE p_table_update
    @pkfield INT,
    @field1 VARCHAR(50),
    @field2 VARCHAR(50) = NULL
AS
UPDATE table SET
    field1 = @field1,
    field2 = @field2
    WHERE pkfield = @pkfield
Is there a way that if I don't send the @field2 parameter, that it gets 'ignored' in the UPDATE statement? Other than writing 2 UPDATE statements of course!

I have tried with CASE, but it looks like CASE can't be used this way! :(
Sylvain Demers
Next
Reply
Map
View

Click here to load this message in the networking platform