Updating GL00100 account segments to inactive "0" and USERDEF2 to 'AllExclude'

I am looking to perform a mass update of GL accounts that need to be marked inactive ( all three segments) and USERDEF2 marked as 'AllExclude'

I would like to get this scripted so that it becomes a routine I can run as needed.

Unfortunately GL00100 is comprised of multiple segments (ACTNUMBR_1, 2, 3 . . .), our GL accounts have three segments so I ran the following to update by range ( I sorted the ranges for each segment in Excel and added a comma at the end of each )

       update gl00100 set active=0 where actnumbr_3= ' range of segments'

While I was able to run this and it worked I do however need to update one more field USERDEFINED2, I am not sure fo the most efficient way to do this as

ACTNUMBR 1, 2 & 3 are not unique, I am not sure the best means to update the 300 accounts to 'AllExclude".

Could someone lend me a hand, I'm almost there.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

manelson05Author Commented:
I have cobbled this together for one test case, it does work however is there a way to pass the data from each Excel column to SQL or am I going to have to manually copy and past all the data for each ACTNUMBR?

update GL00100 set USERDEF2 ='AllExclude'
      where ACTNUMBR_1 ='0536'
      and ACTNUMBR_2 ='40108'
            and ACTNUMBR_3 = '00000'
manelson05Author Commented:
Can I use a temp table and upload the data to the table for future use? If I could go this route then I could run an integration from Excel and have the user upload the data to the temp table then simply run the script.

Would this work?
Victoria YudinOwner / Dynamics GP ConsultantCommented:
What are you starting with, a list of the full account numbers? If so, get them into a list with commas, for example: ('111-2222-333','222-4444-333','333-5555-666')
then you use the following code, replace YourListofAccounts with the comma delimited list of the full account numbers:
update GL00100
set ACTIVE = 0,
USERDEF2 = 'AllExclude' 
where ACTINDX in
 select ACTINDX from GL00105 where
 ACTNUMST in (YourListofAccounts)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

manelson05Author Commented:

The excel sheet I was given has all the accounts broken out by segments.
I am going to try this as the GL00105 lists the actual full account and you are using ACTINDX to do so.

Thank you, I will post back my results later today.

manelson05Author Commented:
I just tried this code with the full accounts with commas:

update GL00100
set ACTIVE = 0,
USERDEF2 = 'AllExclude'
where ACTINDX in
 select ACTINDX from GL00105 where

This is the error  I just received, strange account number thrown up as this is not among my entries.

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '6001-40105-01133
manelson05Author Commented:
I added the apostrophes and it ran fine
Victoria YudinOwner / Dynamics GP ConsultantCommented:
Yep, since the account number is a string, you always need the single quotes around it. :-)
manelson05Author Commented:
Very helpful and helped me to not over complicate my solution. Victorias code is cleaner than mine and this shows her years of experience.

Thank you Victoria! I appreciate you!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Dynamics

From novice to tech pro — start learning today.