SQL Trigger Max Length

Hello,

I have the below trigger which works fine. I want to amend the trigger to only INSERT a maximum length of 30 characters. Can you please assist?


CREATE TRIGGER TRANSHEADERS_CustomerRef_Update  
ON Transheaders  
FOR INSERT AS  
BEGIN  
    UPDATE TRANSHEADERS
Set ZCustomerRef = ExtraText
Where AccountID = 'CAWWWEBXXXX' AND TransactionType = 'CO'  

END
jspcAsked:
Who is Participating?
 
Nitin SontakkeDeveloperCommented:
You refer to INSERT while trigger is updating the table. I see that the trigger itself is on INSERT operation. Which column are you referring to for max length of 30 is not clear.

From where ExtraText coming is also not clear.

update [transheaders] set
  [ZCustoerRef] = substring([ExtraText], 1, 30)
where [AccountID] = 'CAWWWEBXXXX' 
  AND [TransactionType] = 'CO'   

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.