Question

Raju Sarikonda on Fri, 07 Feb 2014 02:52:48


One of our previous collegue left a work around to update records besaed on below query. He mentioned, if we see any rows for below query then update notetext or remove it. When we see this today we are surprised that it returned rows, but the notetext does not have any CK_ in that. Not sure how SQL server is seraching this string and not sure how this value gets stored into database. Any help?

select notetext from <tablename> where notetext like '%CK_%'

Note: we saw some spaces in notetext and not sure if that represents CK_

Raju Sarikonda


Sponsored



Replies

Latheesh NK on Fri, 07 Feb 2014 03:08:21


IT would fetch all records with notetext %CK[any character]%

Try the below to understand the same:

create Table [Transaction Table](
Status Varchar(50))
Insert into [Transaction Table] Select  'Successful'
Insert into [Transaction Table] Select  'Successful'
Insert into [Transaction Table] Select  'Fail'
Insert into [Transaction Table] Select  'FailCK'
Insert into [Transaction Table] Select  'CK_'
Insert into [Transaction Table] Select  'FAIL_CK_'
Insert into [Transaction Table] Select  'FailCKAB'
Insert into [Transaction Table] Select  'FailCK '
Insert into [Transaction Table] Select  'Acknowledgement '
select status from [Transaction Table] where status like '%CK_%'
Drop table [Transaction Table]