CREATE PROCEDURE [PostVote]
@PID nvarchar(100),
@UserID nvarchar(100),
@IP nvarchar(15),
@return int =0 output
AS
BEGIN
declare @time datetime
select @time=[Time] from [Vote] Where [UserID]=@UserID
select @time=isnull(@time,dateadd(hh,-2,getdate())
if datediff(hh,getdate(),@time)>1 --这个地方提示语法错误,请问该怎么写?
begin
Update [Photos] Set [Vote]=[Vote]+1 Where ID=@PID
Insert into [Vote](PhotoID,UserID,IP) Values(@PID,@UserID,@IP)
select @return=1
end
END
GO
@PID nvarchar(100),
@UserID nvarchar(100),
@IP nvarchar(15),
@return int =0 output
AS
BEGIN
declare @time datetime
select @time=[Time] from [Vote] Where [UserID]=@UserID
select @time=isnull(@time,dateadd(hh,-2,getdate())
if datediff(hh,getdate(),@time)>1 --这个地方提示语法错误,请问该怎么写?
begin
Update [Photos] Set [Vote]=[Vote]+1 Where ID=@PID
Insert into [Vote](PhotoID,UserID,IP) Values(@PID,@UserID,@IP)
select @return=1
end
END
GO
@PID nvarchar(100),
@UserID nvarchar(100),
@IP nvarchar(15),
@return int =0 output
AS
BEGIN
declare @time datetime
select @time=[Time] from [Vote] Where [UserID]=@UserID
select @time=isnull(@time,dateadd(hh,-2,getdate()))
if datediff(hh,getdate(),@time)>1 --这个地方提示语法错误,请问该怎么写?
begin
Update [Photos] Set [Vote]=[Vote]+1 Where ID=@PID
Insert into [Vote](PhotoID,UserID,IP) Values(@PID,@UserID,@IP)
select @return=1
end
END
GO
少了一边括号
@PID nvarchar(100),
@UserID nvarchar(100),
@IP nvarchar(15),
@return int =0 output
AS
BEGIN
declare @time datetime
select @time=[Time] from [Vote] Where [UserID]=@UserID
set @time=isnull(@time,dateadd(hh,-2,getdate()))--
if (datediff(hh,getdate(),@time)>1) --
begin
Update [Photos] Set [Vote]=[Vote]+1 Where ID=@PID
Insert into [Vote](PhotoID,UserID,IP) Values(@PID,@UserID,@IP)
select @return=1
end
END
GO
select @time=isnull(@time,cast(dateadd(hh,-2,getdate()) as datetime))