Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving some rows...

Status
Not open for further replies.

lassala

Programmer
May 17, 2001
8
BR
Hi, Everybody!

Imagine the following situations:

I'd like to bring from a table, just people from a list of Countries? How could I do the select statement... something as

select * from table
where inlist(country,'brazil','usa','france')

Well, I'll pass to some function a list of possible values of my table...

Is there some way?
 
Create a stored procedure that create and executes a SQL statement.

Create procedure ListPeopleFromCountries @ctry varchar(1024) As

Declare @sql nvarchar(2000)
Set quoted_identifier OFF

Set @sql="Select * From tblname Where Country In (" + @ctry + ")"

Execute(@sql)
GO

Call the stored procedure like this.

exec ListPeopleFromCountries "'brazil','usa','france'" Terry

"I'm not dumb. I just have a command of thoroughly useless information." - Calvin, of Calvin and Hobbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top