p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2000 > SQL Server 2000
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 1st, 2004, 09:26 AM
Authorized User
Points: 118, Level: 2
Points: 118, Level: 2 Points: 118, Level: 2 Points: 118, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stored Procedure...

Hi,
How do I write a stored procedure for the below SQL Query.

select UserID,UserName from [User] where UserID in (1,4,5)

Meaning: I would like to have a way for my Stored Procedure to pass 1,4,5 as a parameter. The number of IDs is going to be dynamic... Can I have a text as param and a mechanism in which i can do a split and ...
Please Help!

Advice,
Babloo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 1st, 2004, 08:15 PM
Friend of Wrox
Points: 1,335, Level: 14
Points: 1,335, Level: 14 Points: 1,335, Level: 14 Points: 1,335, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

You may want to try something like this, hopefully it will give you and idea.

CREATE PROCEDURE get_User_info
@UserName varchar (20)
@userID Int output
as
SELECT @UserName= UserName
FROM [user]
WHERE UserID = @UserID
return
go



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old May 2nd, 2004, 12:25 AM
Friend of Wrox
Points: 3,152, Level: 23
Points: 3,152, Level: 23 Points: 3,152, Level: 23 Points: 3,152, Level: 23
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 922
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Yahoo to melvik
Default

sure u can! i guess u need something like this:

Code:
CREATE PROCEDURE dbo.ProcName
@Users varchar (50)
AS
 DECLARE @SelectText varchar(500)
  SET @SelectText = 'SELECT UserID,UserName FROM [User] WHERE UserID in('+@Users+')'
  EXECUTE (@SelectText)
GO
HTH.

Always:),
Hovik Melkomian.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure prashant_telkar SQL Server 2000 1 July 9th, 2007 08:57 AM
Stored Procedure jezywrap SQL Server ASP 1 January 3rd, 2007 12:29 AM
stored procedure kdm260 SQL Server 2000 2 June 19th, 2006 05:45 PM
Stored Procedure rajanikrishna SQL Server 2000 0 July 18th, 2005 06:01 AM
Help About Stored Procedure zhuge6 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 May 20th, 2005 10:27 AM



All times are GMT -4. The time now is 08:28 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc