Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

Sql Query Help

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I need to add 4 zeros to the start of all exsisting item lookup codes. Would anyone know a sql query to achieve this?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sql Query Help

    Thanks worked perfect

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sql Query Help

    My SQL Server 2005 is a little rusty, but I think he plus sign (+) acts as a concatenate operator in SS2005;

    First try this

    SELECT ITEMLOOKUPCODE, '0000'+ITEMLOOKUPCODE AS NEW_ILC

    FROM ITEM

    If it looks good, you can do an update  -  backup your database first

    UPDATE ITEM

    SET ITEMLOOKUPCODE =  '0000'+ITEMLOOKUPCODE

    Would also suggest you backup your db, restore as a "testing" database, and run the update statement on your test db first, in case you have ILCs that are less than four characters from the limit of the ILC field.

    Another option is to keep your ILC but insert the ILC with the four zeroes as an ALIAS

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans