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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 getting answers from both columns

Author  Topic 

cjhardie
Yak Posting Veteran

58 Posts

Posted - 2006-09-20 : 10:59:35
c.firstname + ' ' + c.lastname like '%'+@contact+'%'

I don't know how to explain this but, is this correct?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-20 : 11:12:41
Looks fine to me.

What do you want to do? Want to concatenate two columns and search the concatenated value for something?

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

cjhardie
Yak Posting Veteran

58 Posts

Posted - 2006-09-20 : 11:32:04
ok when i put this(there is more sql but it is of no value) into micorsoft visual and i search on my web page for a name i get nothing. It is a little different on C# but this is the sql statement. does it look right?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-20 : 11:36:47
But why would you use a leading %. It will cause a scan


USE Pubs

DECLARE @contact varchar(50)
SELECT @contact = 'Victoria Ashworth'

SELECT *
FROM employee
WHERE fname + ' ' + lname like '%'+@contact+'%'




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-20 : 11:37:35
quote:
Originally posted by cjhardie

ok when i put this(there is more sql but it is of no value) into micorsoft visual and i search on my web page for a name i get nothing. It is a little different on C# but this is the sql statement. does it look right?



You should be calling stored procedures andexecuting the sql from within there



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
   

- Advertisement -