SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

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

Create Proc [dbo].cs_Posts_Views_Add
(
	@PostID int,
	@AggCount int,
	@WebCount int
)

as
SET Transaction Isolation Level Read UNCOMMITTED

Update cs_Posts
Set 
	TotalViews = TotalViews + @WebCount,
	AggViews = AggViews + @AggCount
Where 
	PostID = @PostID

declare @ThreadID int
set @ThreadID = (select ThreadID from cs_Posts where PostID = @PostID)

update cs_Threads
set
	TotalViews = TotalViews + @WebCount
where
	ThreadID = @ThreadID

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

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