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


String Comparision failing


String Comparision failing

Author
Message
Achilies
Achilies
Old Hand
Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)

Group: General Forum Members
Points: 341 Visits: 456
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?
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26319 Visits: 17553
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 Modens 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)
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39860 Visits: 38563
What version of SQL Server are you using? Are just getting nothing in return or are there any error messages.

Cool
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)
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39860 Visits: 38563
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.

Cool
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)
Achilies
Achilies
Old Hand
Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)Old Hand (341 reputation)

Group: General Forum Members
Points: 341 Visits: 456
Soundex worked.

Thanks
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26319 Visits: 17553
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 Modens 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)
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