Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9282393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:21:52+00:00 2026-06-18T18:21:52+00:00

I have a table called service entry which has a field called part description,

  • 0

I have a table called service entry which has a field called part description, Sample data is as follows:

**dbo.ServiceEntry**
ID      PartDescription
1200  60009 ~ Slide Error ~ L 0 ~ P 0 | 60011 ~ RV loader - Pick/Place Homing Error ~ L 0 ~ P 0 

I then have a table called ServiceEntryPart which has a 1 to many relationship, one service entry can have multiple parts in it, hence the service entry part table

**dbo.ServiceEntryPart**
ID  ServiceEntry   PartID   OldPartID
1    1200          5000     60009
2    1200          5500     60011


**dbo.Part**
ID     Description                           OldPartID
5000   New Slide Description                 60009
5500   Xyz                                   60011

Im trying to write a script to update the partdescription column in the ServiceEntry Table so the expected results will look like following with the new part id. so its basically just replacing the old part ids with the new ones

OLD OUTPUT

60009 ~ Slide Error ~ L 0 ~ P 0 | 60011 ~ RV loader - Pick/Place Homing Error ~ L 0 ~ P 0

NEW OUTPUT

5000 ~ New Slide Description ~ L 0 ~ P 0 | 5500 ~ Xyz ~ L 0 ~ P 0

I need some help with the script.query to update this fields with the new part id if present:

 1. Get the existing field
 DECLARE @PartDescription VARCHAR(8000)
 SELECT @PartDescription =  PartDescription FROM
 ServiceEntry

 2. UPDATE ServiceEntry
    SET PartDescription
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:21:53+00:00Added an answer on June 18, 2026 at 6:21 pm
    DECLARE @ServiceEntry TABLE(
            ID INT,
            PARTDescription VARCHAR(MAX)
    )
    
    DECLARE @ServiceEntryPart TABLE(
            ID   INT,
            ServiceEntry   INT,
            PartID INT,
            OldPartID INT
    )
    
    DECLARE @Part TABLE(
            ID  INT,
            [Description]  VARCHAR(50),
            OldPartID VARCHAR(50)
    )
    
    INSERT INTO @ServiceEntry SELECT 1200, ''
    
    INSERT INTO @ServiceEntryPart SELECT 1, 1200, 5000, 60009
    INSERT INTO @ServiceEntryPart SELECT 2, 1200, 5500, 60011
    
    INSERT INTO @Part SELECT 5000, 'New Slide Description', 60009
    INSERT INTO @Part SELECT 5500, 'Xyz', 60011
    
    UPDATE @ServiceEntry
    SET PARTDescription = 
            ( 
                SELECT  CAST(p.ID AS VARCHAR)+ ' ~ ' + p.Description + ' ~ L 0 ~ P 0 | '
                FROM    @Part p INNER JOIN  
                        @ServiceEntryPart ep ON p.ID = ep.PartID
                WHERE   ep.ServiceEntry = se.ID
                FOR XML PATH('')
            ) 
    FROM    @ServiceEntry se
    
    UPDATE @ServiceEntry
    SET PARTDescription = LEFT(PARTDescription, LEN(PARTDescription) -2)
    
    SELECT *
    FROM @ServiceEntry
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called service order which has columns called From and To.
i have table called as Support, which have a field named Name and contains
I have table called posts in my DB. Each post has field called social_network
i have 2 tables 1st table called services has id_service, name, date. description 2nd
In my web-service i have a user table which contains column called HITS,now as
I have a table called service entry. In a service entry there could be
I have a table called service entry and Im trying to create a concatenated
I have a table called TPM_TASKS which contain all tasks, as well as a
In the database I have a table called SERVICE. For this table I have
I have 2 tables 1st table called services has id_service , name , date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.