Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2005-06-21 : 11:07:37
|
| This is what I have at the moment ... where Firstname like '%' + @name + '%'If I pass the name 'best' the surname 'best' is returnedIf I enter ' best ' nothing is returned whereas 'best' should still return.Please note that I am using the charindex(' ', @name) to find out if there is a firstname and the lastname i.e. 'john brown'Thanks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-21 : 11:11:35
|
Firstname like '%' + rtrim(ltrim(@name )) + '%'Go with the flow & have fun! Else fight the flow |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-21 : 11:11:38
|
I think It will returndeclare @t table (name varchar(20))insert into @t values('best')insert into @t values('best ')declare @s varchar(10)set @s='best 'Select * from @t where name like '%'+@s+'%'MadhivananFailing to plan is Planning to fail |
 |
|
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2005-06-21 : 11:14:05
|
quote: Originally posted by spirit1 Firstname like '%' + rtrim(ltrim(@name )) + '%'Go with the flow & have fun! Else fight the flow 
Hi,The initial post has been slightly changed. Please read the post again. Thanks |
 |
|
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2005-06-21 : 11:16:48
|
| Problem solved.Wat I was missing was:if (charindex(' ', ltrim(rtrim(@Name)))) > 0Thank you all |
 |
|
|
|
|
|