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
 Transact-SQL (2000)
 Partial SELECT statement

Author  Topic 

sjb
Starting Member

3 Posts

Posted - 2006-09-26 : 03:37:35
Hi everyone,
I just want to know if it's possible to do a partial SELECT query on a db column...
Like... do a select where 'name' starting with 'jo' and then the result set will bring back all the names starting with 'jo', displaying 'john', 'johan', 'jonathan', etc....

thanks
SJB

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-09-26 : 03:44:42
somthing like this
Select * from tabelname where name like 'jo%'

Chirag
Go to Top of Page

sjb
Starting Member

3 Posts

Posted - 2006-09-26 : 03:55:08
thanks, I'll give it a try....
But, another thing... hoe can I give it a variable value.
So that anything can be searched for?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-26 : 04:01:28
[code]Select * from Tbl
Where Col like @var + '%'[/code]

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

sjb
Starting Member

3 Posts

Posted - 2006-09-26 : 04:07:18
thanks....
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-09-26 : 04:31:43
you can also use regular expression functions for searching the values have a look at the following sites.

http://www.4guysfromrolla.com/webtech/regularexpressions.shtml
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=27205&SearchTerms=expressions
http://blogs.msdn.com/khen1234/archive/2005/05/11/416392.aspx

Chirag
Go to Top of Page
   

- Advertisement -