updating all other records

Posted by Andrew Welch on Stack Overflow See other posts from Stack Overflow or by Andrew Welch
Published on 2010-04-12T08:50:18Z Indexed on 2010/04/12 8:53 UTC
Read the original article Hit count: 364

Filed under:

Hi, I've got a query below. I want to add a condition that if the parameter of @IsPrestigeFeatured = 0 then update all of the other rows <> PropertyId in the IsprestigeFeatured column to 0 and if @IsPrestigeFeatured = 1 then IsprestigeFeatured = 1 where propertyId = PropertyId.

I've looked into case statements / if statements but I can't seem to get the syntax right. cheers

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)

© Stack Overflow or respective owner

Related posts about sql