madanthrax
IS-IT--Management
Hi all,
I have a select statement with case in it which you guys helped me with a few months ago. Its been running fine, but recently the inputs to the field that is the subject of the case function (SeriesInfo) have been getting a blank leading space which messes up the character count (see code below).
Unfortunately the inputs to the MSSQL database are done by another department which has recently started employing monkeys to input the data, who only seem to use copy/paste. Repeated attempts to get them to cooperate have failed. I would like to use the trim function but have no idea what I am doing, or even if its possible within a case statement.
Here is the code with an attempted trim added to it (not working):
The select is running in a view, and the case part is to add an extra column to the view that detects what category of document each row is (1,2,or 3).
So is it possible to trim the SeriesInfo field please, and if so what would be the syntax?
Thanks in advance for any help you can give me.
Anthony.
I have a select statement with case in it which you guys helped me with a few months ago. Its been running fine, but recently the inputs to the field that is the subject of the case function (SeriesInfo) have been getting a blank leading space which messes up the character count (see code below).
Unfortunately the inputs to the MSSQL database are done by another department which has recently started employing monkeys to input the data, who only seem to use copy/paste. Repeated attempts to get them to cooperate have failed. I would like to use the trim function but have no idea what I am doing, or even if its possible within a case statement.
Here is the code with an attempted trim added to it (not working):
Code:
SELECT TOP (100) PERCENT PubId, Title, Language, LanguageName, ElectronicFile, FileSize, SeriesInfo, Released, Issued, StatusId, Type, SeriesText, CASE WHEN SUBSTRING(trim(SeriesInfo, 4, 1)) = 'R' THEN '1' WHEN SUBSTRING(SeriesInfo, 3, 1) = 'R' THEN '1' WHEN SUBSTRING(SeriesInfo, 1, 4) = 'SF-1' THEN '3' ELSE '2' END AS Category
The select is running in a view, and the case part is to add an extra column to the view that detects what category of document each row is (1,2,or 3).
So is it possible to trim the SeriesInfo field please, and if so what would be the syntax?
Thanks in advance for any help you can give me.
Anthony.
"Nothing is impossible until proven otherwise"