ALTER PROCEDURE [dbo].[prc_Messages_Sent_Select_All]
@FromProfileID INT
AS
BEGIN
SET NOCOUNT ON
SELECT
a.[MessageID],
a.[ProfileID],
a.[FromProfileID],
a.[FromUsername],
b.[UserName] AS SentToUserName,
a.[Subject],
a.[Body],
convert(varchar, a.[MsgDate], 107) AS zdate,
a.[MsgDate],
a.[MsgRead],
a.[MsgReplied],
a.[MsgNew],
a.[ReplyOfMessageID],
a.[InitialMessageID]
FROM
[tbl_Messages] a
INNER JOIN
[tbl_Profile] b
ON
a.[ProfileID]=b.[ProfileID]
WHERE
a.[FromProfileID] =@FromProfileID AND
a.[MsgNew]=0
ORDER BY
a.[MsgDate] DESC
END
GO
|