SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 3rd, 2004, 04:01 AM
p0134880 p0134880 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 p0134880 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
stored procedure help

In asp this can be done .......

Function getName(ID)
Select Name from User where UserId = ID
return Name
End Function

Select ID from IDtable
<%=getName(ID)%>

how can i do this in stored procedure????

Reply With Quote
  #2  
Old March 3rd, 2004, 09:01 AM
sypher sypher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Montreal
Posts: 92 sypher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 10 sec
Reputation Power: 5
create CREATE PROCEDURE MYSP @ID integer, @Name varchar(50) OUTPUT
as

Select @Name= name from User where UserId = @ID
return Name

To execute it:
DECLARE @Name varchar(50)
EXECUTE MYSP 2, @Name OUTPUT
--2 being the @id

If @Name is ='your'
begin
....
end

Reply With Quote
  #3  
Old March 3rd, 2004, 08:19 PM
p0134880 p0134880 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 p0134880 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the table looks like this

--------------------
id (id table)
--------------------
1
2
3
4
---------------------


---------------------
id | Name (Name table)
---------------------
1 | rec1
1 | rec2
3 | rec3
4 | rec4
---------------------

then who do i get all the names out that reference to the same id???

Reply With Quote
  #4  
Old March 4th, 2004, 04:39 PM
scienco scienco is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 44 scienco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 9 sec
Reputation Power: 5
Check out the link to someone who's covering INNER JOINS on the main MSSQL page. - That's what you need, by the sounds of it.
__________________
<%Questions of Science%>

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > stored procedure help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway