SqlSetLPacket%

Sets the tabular data stream (TDS) packet size in a SQL Server login record.

Syntax

SqlSetLPacket% ( loginrec%, packetsize% )

where

loginrec%
A login record, which is passed as a parameter to SqlOpen%. The value of loginrec% is returned by SqlLogin%.
packetsize%
The size requested, in bytes (0 through 65535). The server will set the actual packet size to a value less than or equal to the requested size.

Returns

succeed (1) or fail (0).

Remarks

Tabular data stream (TDS) is an application protocol used for the transfer of requests and request results between clients and servers. TDS data is sent in fixed-size chunks, called "packets." TDS packets have a default size set by SQL Server. If an application does bulk copy operations, or sends or receives large amounts of text or image data, a packet size larger than the default might improve efficiency, since it results in fewer network reads and writes. For large data transfers, a packet size between 4092 and 8192 is usually best. Any larger size can degrade performance.

The only way an application can change the TDS packet size is by using SqlSetLPacket%. If SqlSetLPacket% is not called, all SQL Server connections in an application will use the default size.

Note that when the application logs in to the server, the server sets the TDS packet size for that SQL Server connection to be equal to or less than the value of the packetsize% parameter. If the server is experiencing space constraints, the packet size is set to a value less than the value of the packetsize% parameter. Otherwise, the packet size is equal to the value of this parameter. To determine the packet size that the server has set, call SqlGetPacket%.

Different SQL Server connections in an application can use different packet sizes. To set different packet sizes for connections, an application can either change the packet size in a single login record between the SqlOpen% calls that create the connections, or it can set different packet sizes in multiple login records structures and use these different login records when creating the SQL Server connections.

See Also

SqlGetPacket%, SqlLogin%, SqlOpen%