May 31, 2013 at 12:16 pm
Hi I am trying to do string comparision using difference function
When tried this way:
Declare @a varchar(50), @b-2 varchar(50)
set @a='Kelly'
set @b-2='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=@Fnameand C.LastName=@Lnameand 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?
May 31, 2013 at 1:56 pm
What exactly are you trying to do?
And why all the NOLOCKS?
http://www.jasonstrate.com/2012/06/the-side-effect-of-nolock/[/url]
_______________________________________________________________
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 http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 31, 2013 at 2:45 pm
What version of SQL Server are you using? Are just getting nothing in return or are there any error messages.
May 31, 2013 at 2:49 pm
I ran this:
select
soundex('Kelly'),
soundex('Bentom'),
soundex('Kelly'),
soundex('Benton')
And got this:
K400B535K400B535
Looks to me that your code is working.
May 31, 2013 at 3:00 pm
Soundex worked.
Thanks
May 31, 2013 at 3:04 pm
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 http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply