I have a table and xml data as below for example:
IF EXISTS(
SELECT table_name FROM information_schema.tables
WHERE table_name = 'JobCandidates')
DROP TABLE JobCandidates;
-- Create JobCandidates table
CREATE TABLE JobCandidates(
CandidateId INT PRIMARY KEY,
-- Create typed XML column
CandidateResume XML
(DOCUMENT HumanResources.HRResumeSchemaCollection) NULL,
-- Create untyped XML column
CandidateRating XML NULL);
-- Insert data into the typed column
INSERT INTO JobCandidates (CandidateId, CandidateResume)
(SELECT JobCandidateId, [Resume]
FROM HumanResources.JobCandidate
WHERE JobCandidateId = 1);
UPDATE JobCandidates
SET CandidateRating =
'<Ratings>
<Rating Ratingtype="unknown">
<AppliedKnowledge>3.0</AppliedKnowledge>
<ToolSkills>3.5</ToolSkills>
</Rating>
<Rating Ratingtype="known">
<Experience>9.5</Experience>
<Education>16.0</Education>
<DbDevelopment>4.5</DbDevelopment>
</Rating>
<Rating Ratingtype="unknown">
<AppliedKnowledge>4.0</AppliedKnowledge>
<ToolSkills>4.5</ToolSkills>
</Rating>
</Ratings>';
SELECT * FROM JobCandidates;
My requirement: Assuming this table has thousand records and I need to search for xml column for <Rating Ratingtype="unknown"> <data> </Rating>
and replace it with <SuperRating Ratingtype="unknown"> <data> </SuperRating>