SQL - @@PACKET_ERRORS Function
The SQL @@PACKET_ERRORS statistical function is used to retrieve the network packet errors. It returns the total number of network packet errors, that occurred on SQL server connections since the SQL server was last started.
Syntax
Following is the syntax of the SQL @@PACKET_ERRORS function −
@@PACKET_ERRORS
Return type
The return type of this function is an INTEGER.
Parameters
It does not accept any parameters.
Return value
This function returns the number of network packet errors.
Example
In the following example,we are using the SQL @@PACKET_ERRORS function to retrieve the number of network packet errors that have occurred on SQL server connections.
SELECT @@PACKET_ERRORS AS Packet_error;
Output
Following is the output of the above query −
+--------------+ | Packet_error | +--------------+ | 0 | +--------------+
Example
The following is another example of the SQL @@PACKET_ERRORS function. You can also use the GETDATE() function along with this function to retrieve the number of packet errors until today, that have occurred on SQL server connections since it was last started.
SELECT @@PACKET_ERRORS AS Packet_error, GETDATE() AS Curr_date;
Output
The above SQL statement produces the following output −
+--------------------+-------------------------+ | Total_packet_error | Curr_date | +--------------------+-------------------------+ | 0 | 2023-03-01 10:22:46.730 | +--------------------+-------------------------+