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
 General SQL Server Forums
 New to SQL Server Programming
 stored procedure and many to many relation

Author  Topic 

opi
Starting Member

29 Posts

Posted - 2008-03-13 : 10:05:20
Hi,

This is my table setup

[url]http://www.mshelp.be/img/logs.JPG[/url]

I want to retrieve the logs by profileId.

This is the stored procedure which I'm using. Don't get any syntax error, only not the correct output.


create procedure sp_Select_log_By_ProfileId
@ProfileId int
as
select
l.LogId, l.LogDescription, l.CreatedOn, l.LogAuthorId
from
Logs l inner join ProfileLogs pl
on
pl.LogId = l.LogId
where
pl.ProfileId = @ProfileId;


Can anyone help me ?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-13 : 10:19:38
Do you have records in the table?

As suggested before, please read and follow the advice in this blog post
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

opi
Starting Member

29 Posts

Posted - 2008-03-13 : 10:25:30
Yes, there is date in all 3 tables.
The sp should be ok, no ?
Go to Top of Page

opi
Starting Member

29 Posts

Posted - 2008-03-13 : 10:33:17
Damn, how stupid of me
There was already a sp from before with a spelling error, that gave the wrong output,

Can I delete this post?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-13 : 10:34:47
Why? Let it be so that other people can learn from this experience.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

opi
Starting Member

29 Posts

Posted - 2008-03-13 : 10:40:28
Thanks for all your help Peso
Go to Top of Page
   

- Advertisement -