我在下面有一个查询。我想添加一个条件,如果@IsPrestigeFeatured = 0
的参数然后更新所有其他行<> IsprestigeFeatured列中的PropertyId
为0,如果@IsPrestigeFeatured = 1
则为IsprestigeFeatured = 1 where propertyId = PropertyId
。
我查看了case语句/ if语句,但我似乎无法正确使用语法。 欢呼声
ALTER PROCEDURE dbo.Update_Property
@propertyId int,
@propertyTypeId int,
@Name ntext,
@Price int,
@DescriptionResultsExcerpt text,
@Description ntext,
@Characteristics ntext,
@IsRenovation int,
@IsCharacter int,
@IsPrestige int,
@IsHomepageFeatured int,
@IsPrestigeFeatured int,
@CityId int,
@DepartmentId int,
@CommuneId int
As
UPDATE Property
SET Name = @Name, PropertyTypeID = @propertyTypeId, Price = @Price,
DescriptionResultsExcerpt = @DescriptionResultsExcerpt,
Description = @Description, Characteristics = @Characteristics,
IsRenovation = @IsRenovation, IsCharacter = @IsCharacter,
IsPrestige = @IsPrestige, IsHomepageFeatured = @IsHomepageFeatured,
IsPrestigeFeatured = @IsPrestigeFeatured, CityId = @CityId,
DepartmentId = @DepartmentId, CommuneId = @CommuneId
FROM Property
WHERE (PropertyId = @PropertyId)
答案 0 :(得分:1)
答案 1 :(得分:0)
ALTER PROCEDURE dbo.Update_Property
@propertyId int, @propertyTypeId int, @Name ntext, @Price int,
@DescriptionResultsExcerpt text, @Description ntext,
@Characteristics ntext, @IsRenovation int, @IsCharacter int,
@IsPrestige int, @IsHomepageFeatured int,
@IsPrestigeFeatured int, @CityId int,
@DepartmentId int, @CommuneId int
As
UPDATE
Property
SET IsPrestigeFeatured = @IsPrestigeFeatured
WHERE
(@IsPrestigeFeatured = 0 AND PropertyId <> @PropertyId) OR
(@IsPrestigeFeatured = 1 AND PropertyId = @PropertyId)