Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Newbie Help Needed

Author  Topic 

saintwade
Starting Member

2 Posts

Posted - 2004-11-11 : 12:30:35
Hi! I am new to obviously new to SQL and have been tasked with substituting some fields in our buyer code field (FBUYER) within the item master table (INMAST) in or SQL 2000 DB.

Overview: in INMAST, based on current value of FPRODCL make changes to FBUYER.

Detail:

1) select all records where FBUYER = LLN or LLV. Make no changes to these elements

2) all other records where FBUYER not = to LLN or LLV: change as follows

if FPRODCL= change FBUYER

0x = 0
1x = 1
2x = 2
5x = 5

If you can tell me what the code should be, I would appreciate it. I would also appreciate just a point in the right direction.

Thanks, Wade

amachanic
SQL Server MVP

169 Posts

Posted - 2004-11-11 : 14:09:02
If I understand your requirements, I think you want:

UPDATE INMAST
SET FBUYER =
CASE FPRODCL
WHEN '0x' THEN '0'
WHEN '1x' THEN '1'
WHEN '2x' THEN '2'
WHEN '5x' THEN '5'
END
WHERE FBUYER NOT IN ('LLN', 'LLV')
Go to Top of Page

saintwade
Starting Member

2 Posts

Posted - 2004-11-11 : 17:59:31
amachanic,

Thanks!

I have a test database that I will run this on and adjust as necessary.

Wade
Go to Top of Page
   

- Advertisement -