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?
-
SELECT LEN(columnName) AS MyLength FROM myTable
From Brian R. Bondy -
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 tablenameFrom Joseph Pecoraro -
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 .
From sivasankar
0 comments:
Post a Comment