Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

String Comparision failing Expand / Collapse
Author
Message
Posted Friday, May 31, 2013 12:16 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, August 13, 2014 9:11 AM
Points: 257, Visits: 436
Hi I am trying to do string comparision using difference function
When tried this way:

Declare @a varchar(50), @b varchar(50)
set @a='Kelly'
set @b='Bentom'
select FirstName,LastName,dataLENgth(FirstName),dataLENgth(LastName),dataLENgth(@a),dataLENgth(@b),
Difference(FirstName,@a),Difference(LastName,@b)
from Customer with (nolock) where CustomerId=1615333

I am getting the difference=4

but when tried in in SP:
Alter Proc FV_SP_NameMatch
(
@Product int ,
@Fname varchar(50) ,
@Lname varchar(50) ,
@dob datetime ,
@zipcode char(10)
)
As
select e.acctId AcctId,C.Firstname,C.Lastname,
convert (varchar,c.DateofBirth,101) DateofBirth,a.postalcode
from EmbossingAccounts e with (nolock)
join BSegment_Primary b with (nolock) on b.acctid = e.parent01aid
join Customer c with (nolock) on c.CustomerId = e.CustomerId
join address a with (nolock) on a.customerid = c.CustomerId
and e.Ecreationdate > GETDATE()-1 /* get the cards created in last 24 hours */
and b.parent02aid = @Product /* filter by SG product */
and C.FirstName=@Fname and C.LastName=@Lname and C.DateofBirth=@dob and a.postalcode=@zipcode
where Difference(RTRIM(Ltrim(c.FirstName)),RTRIM(Ltrim(@Fname)))>=2 and Difference(RTRIM(Ltrim(c.LastName)),RTRIM(Ltrim(@Lname)))>=2

--exec FV_SP_NameMatch '50265','Kelly','Bentom','11/17/1972','30341'
it is giving no data.

In table, FirstName=Kelly LastName=Benton

Any clue what i am missing?
Post #1458831
Posted Friday, May 31, 2013 1:56 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:42 AM
Points: 13,279, Visits: 12,112
What exactly are you trying to do?

And why all the NOLOCKS?

http://www.jasonstrate.com/2012/06/the-side-effect-of-nolock/


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1458864
Posted Friday, May 31, 2013 2:45 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 11:42 AM
Points: 23,237, Visits: 31,930
What version of SQL Server are you using? Are just getting nothing in return or are there any error messages.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1458879
Posted Friday, May 31, 2013 2:49 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 11:42 AM
Points: 23,237, Visits: 31,930
I ran this:


select
soundex('Kelly'),
soundex('Bentom'),
soundex('Kelly'),
soundex('Benton')


And got this:


K400 B535 K400 B535



Looks to me that your code is working.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1458881
Posted Friday, May 31, 2013 3:00 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, August 13, 2014 9:11 AM
Points: 257, Visits: 436
Soundex worked.

Thanks
Post #1458883
Posted Friday, May 31, 2013 3:04 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:42 AM
Points: 13,279, Visits: 12,112
Achilies (5/31/2013)
Soundex worked.

Thanks


I suspect you were not clear on how difference works. To be honest it is pretty limited.

http://msdn.microsoft.com/en-us/library/ms188753.aspx


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1458884
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse