jspc
asked on
Trigger for SQL Server 2008
I was provided with a SQL Trigger yesterday by one of your members which works.
I have since discovered the program which inserts the data has a bug whereby it's creating a carriage return and a space before the data.
I was wondering if l can include in the below trigger script a workaround, whereby it removes the left space and carriage return first before the update?
The data type is TEXT. I'm not sure why the developer of the database is using TEXT.
Thanks
CREATE TRIGGER TRANSHEADERS_CustomerRef_U pdate
ON Transheaders
FOR INSERT AS
BEGIN
UPDATE TRANSHEADERS
Set ZCustomerRef = ExtraText
Where AccountID = 'CAWWWEBXXXX'
I have since discovered the program which inserts the data has a bug whereby it's creating a carriage return and a space before the data.
I was wondering if l can include in the below trigger script a workaround, whereby it removes the left space and carriage return first before the update?
The data type is TEXT. I'm not sure why the developer of the database is using TEXT.
Thanks
CREATE TRIGGER TRANSHEADERS_CustomerRef_U
ON Transheaders
FOR INSERT AS
BEGIN
UPDATE TRANSHEADERS
Set ZCustomerRef = ExtraText
Where AccountID = 'CAWWWEBXXXX'
Use LTRIm function to remove spaces and Replace function to remove other characters.
ASKER
Are you able to provide the required script, please?
Just a comment:
Get rid of TEXT. It is deprecated. Also some string functions done work on TEXT, which requires an additional CAST(column TO [N]VARCHAR(MAX)). This is should not be done without very good reasons. And not knowing why it is used is definitly not a good reason.
Get rid of TEXT. It is deprecated. Also some string functions done work on TEXT, which requires an additional CAST(column TO [N]VARCHAR(MAX)). This is should not be done without very good reasons. And not knowing why it is used is definitly not a good reason.
ASKER
I can only work with what I have. I cant change the data type of the database.
Are you suggesting adding more detail to the script, converting it? I don't understand what you mean by CAST.
Are you suggesting adding more detail to the script, converting it? I don't understand what you mean by CAST.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.