Is there a way to convert a column with data in it as TEXT
to VARCHAR(X)
easily? There are no existing records in the column is longer than X
.
The CAST() function converts a value (of any type) into a specified datatype.
You can also use VARCHAR to store short strings—VARCHAR(40), for example—but it can store any string up to the maximum column size, using a variable amount of storage space. Next, TEXT and its variants. Text is based on the BLOB (binary large object) type.
Yes for sure
ALTER TABLE table_name MODIFY column_name VARCHAR(X)
For MS SQL:
ALTER TABLE table_name ALTER COLUMN column_name datatype(value)
For MySQL
ALTER TABLE table_name MODIFY column_name datatype(value)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With