SQL - @@PACK_SENT Function



The SQL @@PACK_SENT statistical function is used to retrieve the number of output packets. It returns the total number of output packets written to the network by the SQL server since it was last started.

Note − In SQL, the Packets are fixed-size chunks of data that transfer requests and responses between clients and servers. The default package size is 4096 bytes(1 byte = 8 bits).

If the SQL server packet size is configured higher than the network packet size, then the overhead of breaking down the TDS packets into multiple packets.

Syntax

Following is the syntax of the SQL @@PACK_SENT function −

@@PACK_SENT

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 output packets.

Example

In the following example,we are using the SQL @@PACK_SENT function to retrieve the number of output packets written to the network by the SQL server.

SELECT @@PACK_SENT AS Output_packets;

Output

The above program produces the following output −

+----------------+
| Output_packets |
+----------------+
| 53711          |
+----------------+

Example

The following is another example of the SQL @@PACK_SENT function. You can also use the GETDATE() function along with this function to retrieve the number of output packets today that have been written to the network by the SQL server since it was last started.

SELECT @@PACK_SENT AS Output_packets, GETDATE() AS Todays_date;

Output

On executing the above program, it will produce the following output −

+----------------+-------------------------+
| Output_packets | Todays_date             |
+------------------------------+-----------+
| 53739          | 2023-03-01 13:56:22.303 |
+----------------+-------------------------+

Example

In this example, we are using the SQL @@PACK_SENT and @@PACK_RECEIVED functions along with the GETDATE() function to retrieve the number of input packets, and the number of output packets until today written to the network by the SQL server.

SELECT @@PACK_RECEIVED as Input_packets, @@PACK_SENT AS Output_packets, GETDATE() AS Todays_date;

Output

Following is the output of the above SQL query −

+---------------+----------------+-------------------------+
| Input_packets | Output_packets | Todays_date             |
+--------------------------------+-------------------------+
| 10254         | 53813          | 2023-03-01 14:09:07.730 |
+---------------+----------------+-------------------------+
sql-statistical-functions.htm
Advertisements