Reputation: 127
ResultSet res
ResultSetMetaData rsmds= res.getMetaData();
int size = rsmds.getColumnDisplaySize(i);
gives the width of a column, I want to get size of a column in bytes. How can I do this?
Query for the result set:
SELECT * FROM LevelOne ORDER BY (SELECT NULL) OFFSET 0 ROWS FETCH NEXT 50000 ROWS ONLY;
create table query:
CREATE TABLE Q_680_6([Id] INT, [Title] NVARCHAR(MAX) DEFAULT '', [Description] VARCHAR(MAX) Dta_db.dbo.Q_680_6([Id] INT, [Title] NVARCHAR(MAX) DEFAULT '', [Description] VARCHAR(MAX) DEFAULT '', [StartDate] DATETIME DEFAULT NULL, [EndDate] DATETIME DEFAULT NULL, [Lead] NVARCHAR(MAX) DEFAULT '', [CreatedOn] DATETIME DEFAULT NULL, [CreatedBy] INT, [ModifiedOn] DATETIME DEFAULT NULL, [ModifiedBy] INT) END
Upvotes: 0
Views: 1799
Reputation: 108941
You can't derive this from the result set metadata. You can use DatabaseMetaData.getColumns(...)
, column CHAR_OCTET_LENGTH
, but this is possibly not populated for data types other than char
/varchar
.
Upvotes: 1
Reputation: 1550
getColumnDisplaySize
is about the result set. It is not about the column specification.
You might find this related discussion useful.
Upvotes: 0