SQL-Server2000 global variable

xiaoxiao2021-03-06  41

Global variables are a special type of variable that will maintain the value of these variables. The global variable begins with the @@ prefix, does not have to declare, they belong to the function of the system definition. 1. @@ rowcount After each T-SQL statement, both the server sets the value of this variable to the total number of records affected by the statement, which can be used to confirm the success of the selection operation: SELECT A, B , c INTO TAB1 from Tab2 WHERE A = 2 if @@ rowcount = 0 Print "No Rows WERE COPIED" 2. @@ error After each T-SQL statement, the server sets the value of this variable to a shaped value: 0 Represents statements to perform successful error Encoding This statement is returned to the corresponding error code. In the Microsoft SQL Server environment, this global variable is the basis for processing errors. Update Tab SET A = 3 WHERE A = 2 Select @INTERRORCODE = @@ error 3. @@ fetch_status Returns the execution status of the last FETCH statement executed during the current connection, often used in the loop of the cursor record to exit cycles condition. 0 Extract the full success -1 fetch statement attempt to read records other than a record set (last record has been read) -2 record loss (other person's simultaneous deletion) 4. @@ cursor_rows As long as the cursor is open, @@ cursor_rows is set to the number of records in the cursor (can be used to circulate the cursor)

转载请注明原文地址:https://www.9cbs.com/read-73688.html

New Post(0)