SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[cs_PrivateMessages_Recipients]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[cs_PrivateMessages_Recipients]
GO


CREATE procedure [dbo].cs_PrivateMessages_Recipients (
	@ThreadID as int,
	@SettingsID as int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED

BEGIN
	SELECT 
		PM.UserID,
		U.UserName
	FROM 
		cs_vw_Users_FullUser U,
		cs_PrivateMessages PM
	WHERE 
		PM.ThreadID = @ThreadID AND
		PM.SettingsID = @SettingsID AND
		PM.UserID = U.cs_UserID
END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

grant execute on [dbo].[cs_PrivateMessages_Recipients] to public
go