-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateRaceDetails.sql
61 lines (56 loc) · 2.69 KB
/
UpdateRaceDetails.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
USE [eRaceClub]
GO
/****** Object: StoredProcedure [dbo].[UpdateRaceDetails] Script Date: 12/02/2007 18:54:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[UpdateRaceDetails](@raceid int,@CarID int,
@MemberID int,
@Place int,
@RunTime varchar(17),
@Penalty varchar(15) = null,
@Comment varchar(1048) )
As
Begin
--@RunTime
declare @runtime1 VARCHAR(17)
set @runtime1 = (Select convert(varchar(10),RaceDate,1)from Race where RaceId = @raceid)
--select @runtime1
set @runtime1 = @runtime1 + ' '+ @RunTime
Select @runtime1
declare @runtime2 DateTime
set @runtime2 =convert(datetime,@runtime1)
Select @runtime2
If @Place = null
begin
set @Place = 999
UPDATE RaceDetail
SET Place=@Place,
RunTime=@runtime2,
Penalty = @Penalty,
Comment=@Comment,
MemberID =@MemberID
WHERE CarID = @CarID AND
RaceID = @RaceID
end
If @@error<>0 AND @@rowcount=0
begin
Raiserror('Error: Update not completed.', 16, 1)
end
Else
begin
UPDATE RaceDetail
SET Place=@Place,
RunTime=@runtime2,
Penalty = @Penalty,
Comment=@Comment,
MemberID =@MemberID
WHERE CarID = @CarID AND
RaceID = @RaceID
end
If @@error<>0 AND @@rowcount=0
begin
Raiserror('Error: Update not completed.', 16, 1)
end
End