- Dirty reads occur when:
- Transaction A inserts a row into a table.
- Transaction B reads the new row.
- Transaction A rolls back.
- Nonrepeatable reads occur when:
- Transaction A reads a row.
- Transaction B changes the row.
- Transaction A reads the same row a second time and gets the new results.
- Phantom reads occur when:
- Transaction A reads all rows that satisfy a WHERE clause on an SQL query.
- Transaction B inserts an additional row that satisfies the WHERE clause.
- Transaction A re-evaluates the WHERE condition and picks up the additional row.
In this article we will learn how to sort the table values with out using dynamic query to improve performance. CREATE PROCEDURE SortingExample ( @sortFiled INT, @sortType INT -- 1 for ASC, 2 for DESC ) AS BEGIN -- Create a table variable to store user data DECLARE @myTable TABLE ( UserID INT IDENTITY(1,1), UserName VARCHAR(50), Password VARCHAR(50), Email VARCHAR(50) ) -- Insert some data to table to work on that data INSERT INTO @myTable(UserName, Password, Email) VALUES ('Jack', 'JackPwd', 'jack@gmail.com') INSERT INTO @myTable(UserName, Password, Email) VALUES ('Anand', 'AnandPwd', 'raj@gmail.com') INSERT INTO @myTable(UserName, Password, Email) VALUES ('smith', 'smithPwd', 'smith@gmail.com') INSERT INTO @myTable(UserName, Password, Email) VALUES ('Brandy', 'BrandyPwd', 'tom@gmail.com') -- If @sortType = 1 then sort the selected field in ASC ord...
Comments
Post a Comment