With Nolock
With (NOLOCK) is equivalent to uncommitted read (read UNCOMMITTED), which means that the specified statement can read rows that have not yet been committed by another transaction modification, transactions that run at the uncommitted read level, and no shared locks are issued to prevent other transactions from modifying the data read by the current transaction. It will not be blocked by an exclusive lock, so with (NOLOCK) can improve the performance of the query by improving the data set lock phenomenon in the environment of online large queries;
SELECT COUNT (UserID) from the employee with (NOLOCK) JOIN Working_group with (NOLOCK) on employee. UserID = Working_group. Userid
String and StringBuilder
The String object is immutable. Each time you use one of the methods in the System.String class, you create a new string object in memory, which requires a new space to be allocated for the new object. The overhead associated with creating a new string object can be very expensive in situations where you need to perform repeated modifications to the string.
If you want to modify a string without creating a new object, you can use the System.Text.StringBuilder class. For example, when you concatenate many strings together in a loop, using the StringBuilder class can improve performance, and when you modify StringBuilder, it does not reallocate space for itself until the capacity is reached. When the capacity is reached, new space is automatically allocated and the capacity doubles.
The length property of the StringBuilder is non-read-only,
If the length property is set to a value greater than the capacity property, the capacity property is automatically changed to the same value as the Length property. If you set the Length property to a value that is less than the length of the string within the current StringBuilder object, the string is shortened.
T-SQL Batch Processing
A batch is a T-SQL statement that acts as a logical unit. If a statement cannot be parsed by parsing, then no statement is run. If a statement fails at run time, the statement before the statement that produced the error is already running.
- The GO statement must be on its own line, and only the comment can be on the same line.
- Each batch is sent separately to the server.
- The GO statement is not a T-SQL command, but a command that is recognized by various SQL Server command utilities such as the query window in Management Studio.
Batching is often used in scripts where things have to be put in front of them or have to be separated from other things (generic DDL statements can only commit one in the same batch)
Use Test ALTER TABLE testtable ADD col3 int INSERT into TestTable (col1,col2,col3) VALUES (1,1,1)
The above code in Query Analyzer prompts the Col3 column does not exist, through a go to solve the problem
Use Test ALTER TABLE testtable ADD col3 int GO INSERT into testtable (col1,col2,col3) VALUES (1, 1, 1)
JavaScript injection attacks
Reference links
Small Knowledge Reserve