Author |
Topic |
kwacz23
Starting Member
44 Posts |
Posted - 2013-08-14 : 03:15:31
|
Hi How I can use function ltrim with Like? last line is not workingSELECT question [AttributeName],response [Value]FROM SC_RequestQuestionDataWHERE request_data_id =11029AND ltrim(question LIKE '%_ATT')Could you help? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-14 : 03:46:08
|
There is no need to LTRIM your column when your criteria starts with a wildcard.What you want is to get all rows where the column Question ends with "ATT".AND Question LIKE '%_ATT'will be enough. If you insist in using LTRIM, this is how it should look likeAND LTRIM(Question) LIKE '%_ATT' Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
kwacz23
Starting Member
44 Posts |
Posted - 2013-08-14 : 03:52:41
|
Thanks for help.However I would like to display results for 'respone' without extra spaces. I am using that but is not help. In this column value are with spaces, I would like to transfer value without this spaceSELECT question [AttributeName],ltrim(rtrim(response))ValueFROM SC_RequestQuestionDataWHERE request_data_id = 11046AND question LIKE '%_ATT' |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-14 : 03:59:14
|
REPLACE(response, ' ', '')--Chandu |
|
|
kwacz23
Starting Member
44 Posts |
Posted - 2013-08-14 : 04:03:25
|
Chandu thanks for you hint, but I would like to only romve first space on the left side if exist. Example ' Win 7 32bit'- here only remove this first extra space.'Win 7 32bit'- here should be as it is now |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-14 : 06:51:05
|
[code]SELECT LTRIM(RTRIM(Question)) AS AttributeName, LTRIM(RTRIM(Response)) AS ValueFROM dbo.SC_RequestQuestionDataWHERE Request_Data_ID = 11046 AND Question LIKE '%_ATT';[/code] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-14 : 08:01:22
|
quote: Originally posted by kwacz23 Chandu thanks for you hint, but I would like to only romve first space on the left side if exist. Example ' Win 7 32bit'- here only remove this first extra space.'Win 7 32bit'- here should be as it is now
SELECT LTRIM(' Win 7 32bit') RemoveLeftSpaceSELECT RTRIM('Win 7 32bit ') RemoveRightSpaceSELECT LTRIM(RTRIM(' Win 7 32bit ')) RemoveBothSpaces--Chandu |
|
|
ShivaKrishna
Starting Member
20 Posts |
Posted - 2013-08-28 : 09:49:58
|
SELECT LTRIM(RTRIM(Question)) AS AttributeName, LTRIM(RTRIM(Response)) AS ValueFROM dbo.SC_RequestQuestionDataWHERE Request_Data_ID = 11046 AND Question LIKE '%_ATT' |
|
|
|