I have a column which is of type nvarchar(max). How do I find the length of the string (or the number of bytes) for the column for each row in the table?
A:
If you want to find out the max there should be a way for you to get the schema of the table. Normally you can do something like SHOW COLUMNS in SQL or a DESCRIBE style command. In a mysql shell that can be shortened to:
desc tablename;
Then if you want to determine the length of a string there is normally a function like LENGTH (for bytes) or CHAR_LENGTH (for characters).
SELECT *, LENGTH(fieldname) AS len FROM tablename
Joseph Pecoraro
2008-08-31 02:51:48
A:
SELECT LEN(columnName) AS MyLength FROM myTable
i used this query for my table it display the size of the each row in that particular column. i need that field name size maximum it allow the characters .
sivasankar
2010-05-31 12:20:12