SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Ltrim rtrim no working with UPDATE


Ltrim rtrim no working with UPDATE

Author
Message
David Burrows
David Burrows
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16209 Visits: 10107
And this should correct the data....

UPDATE #tablename 
SET colname = STUFF(colname,1,1,'')
WHERE colname LIKE '%WDT'
AND colname <> 'WDT'




Far away is close at hand in the images of elsewhere.

Anon.


Sriram-288748
Sriram-288748
Right there with Babe
Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)

Group: General Forum Members
Points: 760 Visits: 340
I have a space on the right side so changed the query accordingly . but afraid it shows no records.

SELECT DISTINCT
[Code] = ASCII(right(LTRIM(valuecode), 1)),
[Character] = '[' + right(LTRIM(valuecode), 1) + ']'
FROM ListOfValues
WHERE (valuecode LIKE '%WDT%')
-- 32 ,[ ]

SELECT valuecode,CAST(valuecode as varbinary(4))
FROM ListOfValues
WHERE valuecode LIKE 'WDT%'
AND valuecode <> 'WDT'
-- No Records

Sriram
David Burrows
David Burrows
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16209 Visits: 10107
You need to do

LIKE '%WDT'

not

LIKE 'WDT%'


Far away is close at hand in the images of elsewhere.

Anon.


Sriram-288748
Sriram-288748
Right there with Babe
Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)

Group: General Forum Members
Points: 760 Visits: 340
Yes David, I have done that rather tried both 1st time only, it returned no records.

Sriram
David Burrows
David Burrows
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16209 Visits: 10107
OK. Maybe there are trailing non printable chars as well, should have thought of that Blush.

Try

LIKE '%WDT%'


Far away is close at hand in the images of elsewhere.

Anon.


Sriram-288748
Sriram-288748
Right there with Babe
Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)Right there with Babe (760 reputation)

Group: General Forum Members
Points: 760 Visits: 340
Thanks for you time friends. could not solve the issue, updated the col to varchar datatype.

Thanks again.

Sriram
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search