Exforsys

Online Training

SELECT Statement - Help

This is a discussion on SELECT Statement - Help within the SQL Server forums, part of the Database category; Hi, I am new into SQL, How to use SELECT statement to fetch records based on a partial match in ...


Go Back   Exforsys > Database > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2006, 01:53 AM
Junior Member
 
Join Date: Feb 2006
Posts: 8
nickole is on a distinguished road
SELECT Statement - Help

Hi,

I am new into SQL, How to use SELECT statement to fetch records based on a partial match in a text field.

Say for ex., I want to retrieve all names with has the "William" in any part of the name field. How to write a query for the above Scenario?

Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-06-2006, 08:06 AM
bhv bhv is offline
Junior Member
 
Join Date: Mar 2006
Posts: 5
bhv is on a distinguished road
Unhappy SQL Server 2005 Help

hi. i am new to SQL server 2005. whenever i tried to create database through SQL sever Management studio, it asked me:
server type: (here i select Database Engine)
server Name : ( ??????????)
Authentication : (Windows Authentiction is by default, another is SQL server Authentication, which one should i select?????????)

i just have no idea what to do with server name. i have Internet Information Services (IIS) installed in my system.

plsssssssssss help me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-06-2006, 02:22 PM
admin's Avatar
Administrator
 
Join Date: Mar 2005
Location: New York, USA
Posts: 302
admin has disabled reputation
Send a message via Yahoo to admin
Please read teh following tutorials on SQL Server 2005...

http://www.exforsys.com/content/view/1616/356/1/1/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-19-2006, 12:47 PM
Junior Member
 
Join Date: Dec 2006
Posts: 1
chaudharyshamraiz is on a distinguished road
Quote:
Originally Posted by nickole View Post
Hi,

I am new into SQL, How to use SELECT statement to fetch records based on a partial match in a text field.

Say for ex., I want to retrieve all names with has the "William" in any part of the name field. How to write a query for the above Scenario?

Thanks in advance.
select ename from table name
where ename like'%William%';
write the table name from where u have to extract the data
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-23-2006, 03:04 PM
Member
 
Join Date: Apr 2006
Posts: 98
Angela is on a distinguished road
If a user wants to give the value only during run time then how can one handle the matching of pattern.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-24-2006, 11:55 PM
Junior Member
 
Join Date: Dec 2006
Posts: 3
neelu.payola is on a distinguished road
is this u want

SQL> create table ex(name char(20),id number);

Table created.

SQL> insert into ex values('&name',&id);
Enter value for name: p will
Enter value for id: 1
old 1: insert into ex values('&name',&id)
new 1: insert into ex values('p will ',1)

1 row created.

SQL> /
Enter value for name: will g
Enter value for id: 2
old 1: insert into ex values('&name',&id)
new 1: insert into ex values('will g',2)

1 row created.

SQL> /
Enter value for name: p will g
Enter value for id: 3
old 1: insert into ex values('&name',&id)
new 1: insert into ex values('p will g',3)

1 row created.




SQL> select * from ex where name like '%will%';

NAME ID
-------------------- ----------
p will 1
will g 2
p will g 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 12-25-2006, 09:40 PM
Senior Member
 
Join Date: Apr 2006
Posts: 153
cyrus is on a distinguished road
nickole our friends have made a detailed resposne to your query.Did you try and did you get the result. Do update us.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-11-2007, 01:46 PM
Junior Member
 
Join Date: Apr 2007
Posts: 8
pegas is on a distinguished road
Quote:
Originally Posted by Angela View Post
If a user wants to give the value only during run time then how can one handle the matching of pattern.
Let's say the value from your program comes in the param @name:

CREATE PROC dbo.GetForAngela @name varchar(100)
AS
BEGIN

SET @name = '%' + @name + '%'

SELECT various_things
FROM AngelasTable
WHERE name LIKE @name

END
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new questions
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:44 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.