Specific part
varchar(MAX) can be used from ADO as an input parameter.
The data type in this case will be adLongVarChar , the maximum length is &h7FFFFFFF , as described here .
It cannot be used as an output parameter. It also cannot be used as a field type in returned records (funny - .Value is Empty , because it is actually a long type, but GetChunk may not be called to retrieve the actual data, since ADO considers it to be not a long type).
If you need to use varchar(MAX) as the output parameter using VBA / ADO, you will need to select return it the recordset for the client, and you will have to pass it to text , doing this
select cast(@var as text) as data; return 0;
Then you would say s = .Fields(0).GetChunk(.Fields(0).ActualSize) to get data from the open recordset.
Abstract part
The point of ADO itself is to abstract the differences between different data sources. Once there is a data access driver that supports the interface, you (ideally) can talk to it without worrying about what it is.
Like any abstraction, it is also leaky .
Accurate knowledge of which data types about which servers map to ADO data types is from experience. I.e.
Some rules of thumb, hovwer, can be developed quickly enough:
It is easy to imagine the possible ADO data types by matching their names with the data type names of a specific server:
int - adIntegerdatetime - adDBDate (although you may be involved in some trial versions and errors here)
Some data types are called BLOBs (binary large objects). They are designed to store a huge amount of data and are usually presented in the documentation of the data source as such. For them, the corresponding ADO data type probably contains Long in its name, which in the ADO world means "BLOB" ( adLongVarBinary , adLongVarChar , adLongVarWChar ).
Any information on the exact length of the data type is contained in the documentation for the data source, and not in the ADO documentation. For things like:
- The maximum length specified by the developer for a specific column in this particular table (e.g.
varchar(10) ) - Maximum theoretical length of a BLOB data type (e.g.
varchar(MAX) )
You are about to access the appropriate data source, not ADO.
source share