340 Part I EXAM PREPARATION Global Variables Global
340 Part I EXAM PREPARATION Global Variables Global variables are not variables. They are actually system functions that return various pieces of information about the current user environment for SQL Server. They are just called functions now, but we aren t going to do that here because the syntax is different, and it would be confusing to call two completely different constructs the same name. A global variable looks like a variable with two at- signs in front of it, as in @@CONNECTIONS, which returns the current number of user connections. You cannot declare global variables and you cannot directly change them with a SET or SELECT statement. So, if you use one of these special functions somewhere, realize that although it looks like a variable and can act like one, you can t assign any data to it; you can only read data from it. Table 6.1 provides a list of the global variables in SQL Server 2000: TABLE 6.1 GLOBAL VARIABLES IN SQL SERVER 2000 Global Variable Function @@CONNECTIONS Returns the current number of connections that applications currently have open to SQL Server. @@CPU_BUSY The time, in milliseconds, that SQL Server has been busy since the last time it was restarted. @@CURSOR_ROWS The number of rows that are in the previously opened cursor. If no cursor has been opened, it returns 0; if the cursor is asynchronous, it returns a negative number representing the number of rows that have been used so far; if the number is positive, it s the number of rows in the cursor; and if the value is -1, the cursor is dynamic, so there s no telling how many rows are in it. Cursors are covered in more detail later in this chapter. @@DATEFIRST Returns the number of the first day of the week. For example, if the first day of the week is set to Sunday, it returns 1, if it s set to Monday, it returns 2, and so on. @@DBTS Returns the current value of the timestamp for the database. This has absolutely no relation to system time, and is only used to manage certain inserts. @@ERROR Returns the error number for the last SQL statement executed. @@FETCH_STATUS Returns the status of the last cursor fetch operation: 0 for success, -1 for failure, or -2 for missing record.
If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.