1
ALTER
PROCEDURE
[
dbo
]
.aspnet_Applications_CreateApplication
2
@ApplicationName
NVARCHAR
(
256
),
3
@ApplicationId
UNIQUEIDENTIFIER
OUTPUT
4
AS
5
BEGIN
6
SELECT
@ApplicationId
=
ApplicationId
FROM
dbo.aspnet_Applications
WHERE
LOWER
(
@ApplicationName
)
=
LoweredApplicationName
7
8![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
IF
(
@ApplicationId
IS
NULL
)
/**/
/*如果应用程序ID为空则进行如下操作*/
9
BEGIN
10
DECLARE
@TranStarted
BIT
11
SET
@TranStarted
=
0
12
13![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
IF
(
@@TRANCOUNT
=
0
)
/**/
/*如果当前连接的活动事务数为零,则开始事务*/
14
BEGIN
15
BEGIN
TRANSACTION
16![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
SET
@TranStarted
=
1
/**/
/*开始事务,设置事务参数为一*/
17
END
18
ELSE
19![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
SET
@TranStarted
=
0
/**/
/*如果当前连接的活动事务数不为零, 设置事务参数为0*/
20
21
SELECT
@ApplicationId
=
ApplicationId
22
FROM
dbo.aspnet_Applications
WITH
(UPDLOCK,
HOLDLOCK
)
23
WHERE
LOWER
(
@ApplicationName
)
=
LoweredApplicationName
24![None.gif](/Images/OutliningIndicators/None.gif)
25![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
IF
(
@ApplicationId
IS
NULL
)
/**/
/*继续判断(不过此处多了WITH)*/
26
BEGIN
27
SELECT
@ApplicationId
=
NEWID
()
28
INSERT
dbo.aspnet_Applications (ApplicationId, ApplicationName, LoweredApplicationName)
29
VALUES
(
@ApplicationId
,
@ApplicationName
,
LOWER
(
@ApplicationName
))
30![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**/
/*如果为空就为表插入新数据,NEWID()创建 uniqueidentifier 类型的唯一值,返回类型为*/
31
END
32
33
34
IF
(
@TranStarted
=
1
)
35
BEGIN
36![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
IF
(
@@ERROR
=
0
)
/**/
/*如果返回错误为0*/
37
BEGIN
38![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
SET
@TranStarted
=
0
/**/
/*重新设置事务参数为0*/
39![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
COMMIT
TRANSACTION
/**/
/*结束事务*/
40
END
41
ELSE
42
BEGIN
43
SET
@TranStarted
=
0
44![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
ROLLBACK
TRANSACTION
/**/
/*回滚事务*/
45
END
46
END
47
END
48
END
49![None.gif](/Images/OutliningIndicators/None.gif)
50
GO
第一个,哈。
![None.gif](/Images/OutliningIndicators/None.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
9
![None.gif](/Images/OutliningIndicators/None.gif)
10
![None.gif](/Images/OutliningIndicators/None.gif)
11
![None.gif](/Images/OutliningIndicators/None.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
14
![None.gif](/Images/OutliningIndicators/None.gif)
15
![None.gif](/Images/OutliningIndicators/None.gif)
16
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
17
![None.gif](/Images/OutliningIndicators/None.gif)
18
![None.gif](/Images/OutliningIndicators/None.gif)
19
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
20
![None.gif](/Images/OutliningIndicators/None.gif)
21
![None.gif](/Images/OutliningIndicators/None.gif)
22
![None.gif](/Images/OutliningIndicators/None.gif)
23
![None.gif](/Images/OutliningIndicators/None.gif)
24
![None.gif](/Images/OutliningIndicators/None.gif)
25
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
26
![None.gif](/Images/OutliningIndicators/None.gif)
27
![None.gif](/Images/OutliningIndicators/None.gif)
28
![None.gif](/Images/OutliningIndicators/None.gif)
29
![None.gif](/Images/OutliningIndicators/None.gif)
30
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
31
![None.gif](/Images/OutliningIndicators/None.gif)
32
![None.gif](/Images/OutliningIndicators/None.gif)
33
![None.gif](/Images/OutliningIndicators/None.gif)
34
![None.gif](/Images/OutliningIndicators/None.gif)
35
![None.gif](/Images/OutliningIndicators/None.gif)
36
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
37
![None.gif](/Images/OutliningIndicators/None.gif)
38
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
39
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
40
![None.gif](/Images/OutliningIndicators/None.gif)
41
![None.gif](/Images/OutliningIndicators/None.gif)
42
![None.gif](/Images/OutliningIndicators/None.gif)
43
![None.gif](/Images/OutliningIndicators/None.gif)
44
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
45
![None.gif](/Images/OutliningIndicators/None.gif)
46
![None.gif](/Images/OutliningIndicators/None.gif)
47
![None.gif](/Images/OutliningIndicators/None.gif)
48
![None.gif](/Images/OutliningIndicators/None.gif)
49
![None.gif](/Images/OutliningIndicators/None.gif)
50
![None.gif](/Images/OutliningIndicators/None.gif)