In employee table, Change the designation of Retail and Sales manager designation as Sales Manager

Designation
Manages(Retail and Sales)
Manager(Production)
Manager(Marketing)
Manager(Shipping and Receiving)
Manager(Shipping and Receiving)
Manager(Marketing)
Manager(Retail and Sales)

 Posted by Sriharim on 6/1/2015 | Category: Sql Server Interview questions | Views: 631 | Points: 40
Answer:

Answer:
The designation can be changed using below update statement. CHARINDEX() function will Searches an expression for another expression (Retail and Sales) and returns its starting position, Stuff() function inserts a string (Sales) into another string (designation column). It also deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.

update employee set designation = Stuff(designation ,CHARINDEX('retail and sales',designation),16,'Sales') from employee where designation like '%retail and sales%'


Asked In: Interview | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Sriharim