Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a CASE to an INT in a Trigger?

Status
Not open for further replies.

dpwsmw

MIS
Apr 2, 2003
76
US
This Trigger Works, But I need to make the case an interger on Division, so when it comes in as 00 it actually puts 2 zeros in instead of one. Is there a way to do it with the Case statement I am using? I really need help with this. Can anyone help?


CREATE TRIGGER [mas_trigger] ON [dbo].[AccountBase]
FOR INSERT
AS
insert mas_001.dbo.AR1_CustomerMaster
(Division, CustomerNumber,CustomerName,TermsCode, SalesPersonCode,
EmailAddress,URLAddress,PhoneNumber,FaxNumber,CreditLimit, action)

select
Case
when CFPDivision = 2 then '00' when CFPDivision = 3 then '10' when CFPDivision = 4 then '20'
when CFPDivision = 5 then '30' when CFPDivision = 6 then '40' when CFPDivision = 7 then '50'
When CFPDivision = 8 then '60' when CFPDivision = 9 then '70' when CFPDivision = 10 then '80'
when CFPDivision = 11 then '90'
end,
AccountNumber,[Name],
case
when PaymentTermsCode = 5 then '00' when PaymentTermsCode = 6 then '01'
when PaymentTermsCode = 7 then '02' when PaymentTermsCode = 8 then '03'
when PaymentTermsCode = 9 then '04' when PaymentTermsCode = 10 then '10'
when PaymentTermsCode = 11 then '15' when PaymentTermsCode = 12 then '20'
when PaymentTermsCode = 13 then '25' when PaymentTermsCode = 14 then '30'
when PaymentTermsCode = 15 then '98' when PaymentTermsCode = 16 then '99'
end,
CFSMAS200Salesperson,EMailAddress1,WebSiteURL,Telephone1,Fax,CreditLimit, 'inserted'
from inserted

 
Integers do not have leading zeros. If you need an integer in the table, but want to display leading zeros when selecting data, handle the formatting on the SELECT not the INSERT.

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top