Cs_censorship_createupdatedelete -- Audit System creation, update, and deletion
Alter proc [DBO]. cs_censorship_createupdatedelete -- Audit System creation update Deletion
(/** // * Refers to some restricted words, such as fuck */
@ Word nvarchar (40)
, @ Deleteword bit = 0
, @ Replacement nvarchar (40)
, @ Settingsid int
)
As
SET transaction isolation level read uncommitted
/** // * Sets the transaction isolation level. Read uncommitted performs dirty read or 0 isolation locks, which means no shared lock is issued,
The exclusive lock is also not accepted. When this option is set, uncommitted read or dirty read can be performed on the data.
Change the value in the data, and the row can also appear in the dataset or disappear from the dataset. The role of this option and all
Set nolock to the same for all tables in the statement. This is the minimum limit among the four isolation levels. */
Set nocount on
/** // * When set nocount is on, no count is returned (the number of rows affected by the transact-SQL statement ).
When set nocount is off, return the count. Update even when set nocount is on
@ Rowcount function. */
If (@ deleteword> 0)
Begin
Delete from
Cs_censorship
Where
WORD = @ word and settingsid = @ settingsid
Return
/** // * Delete a record */
End
Else
Begin
Update cs_censorship set
Replacement = @ replacement
Where
WORD = @ word and settingsid = @ settingsid
/** // * Update and replace the content. For example, the content is replaced by ***, And the content is replaced by another one */
If (@ rowcount = 0) -- if the number of affected rows is 0
Begin
Insert into cs_censorship (
Word, replacement, settingsid
) Values (
@ Word, @ replacement, @ settingsid
)
/** // * Insert a new restricted word */
End
End
Cs_censorships_get
Alter proc [DBO]. cs_censorships_get
(
@ Word nvarchar (40) = '',
@ Settingsid int
)
As
SET transaction isolation level read uncommitted
/** // * Sets the transaction isolation level. Read uncommitted performs dirty read or 0 isolation locks, which means no shared lock is issued,
The exclusive lock is also not accepted. When this option is set, uncommitted read or dirty read can be performed on the data.
Change the value in the data, and the row can also appear in the dataset or disappear from the dataset. The role of this option and all
Set nolock to the same for all tables in the statement. This is the minimum limit among the four isolation levels. */
Select
*
From
Cs_censorship
Where
Settingsid = @ settingsid and (WORD = @ word or (@ word = ''and 1 = 1 ))
/** // * Query the qualified records-_ =! I don't understand why I still add 1 = 1. I always feel that the first 1 is better than the second 1.
It seems to be a little bigger. Is it l or I in upper case? When I did not say .*/
Go