jspc
asked on
Left Trim in SQL
Left Trim - Hello I am wanting to Left Trim a field in a SQL Table. Are you able to provide the script?
The Table is called Transheaders and the data field is called ExtraText
Thanks.
The Table is called Transheaders and the data field is called ExtraText
Thanks.
ASKER
Get this error:
Msg 8116, Level 16, State 1, Line 1
Argument data type text is invalid for argument 1 of ltrim function.
Msg 8116, Level 16, State 1, Line 1
Argument data type text is invalid for argument 1 of ltrim function.
Well, TEXT is a deprecated data type (since years). And most string functions cannot work on it. Cast it to the correct data type. In this case NVARCHAR(MAX).
SELECT LTRIM(CAST(T.ExtraText AS NVARCHAR(MAX))) AS TrimmedExtraText
FROM Transheaders T;
p.s. why do you use still TEXT?
ASKER
Do you think this would work?
UPDATE TRANSHEADERS SET ExtraText = LTRIM(ExtraText)
UPDATE TRANSHEADERS SET ExtraText = LTRIM(ExtraText)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See LTRIM() and T-SQL string functions:
Open in new window
In MySQL: See string functions. It's also LTRIM().
And same for Oracle/PL-SQL (LTRIM()).