Update table using joins and cases


UPDATE Property_New
SET    PropertyNumber = ( CASE
                 WHEN property.StatusId= 4 THEN 1
                 when property.StatusId= 2 THEN 3
                 when property.StatusId= 3 THEN 1
                 when property.StatusId= 6 THEN 1
                 when property.StatusId= 7 THEN 1
                 when property.StatusId= 1 THEN 2
                                END )
FROM Property_New
inner join Property on Property_New.PropertyID=Property.Propertyid

where OrderId=1

Comments

Popular posts from this blog

Grouping Sets, With Rollup and With Cube example

Adding Page brake aganist group values

To Get All the Names of tables and Databases their data have changed in last 24 Hours And Backup those databases