How do you create a table with a column of type NVARCHAR(MAX)?
Posted by TinaGrn
Last Updated: July 23, 2024
To create a table with a column of type NVARCHAR(MAX) in SQL Server, you would use the CREATE TABLE statement. The NVARCHAR(MAX) type is used to store variable-length Unicode strings and can hold up to 2^31-1 characters (approximately 2 GB of data). Here is an example of how to create a table with a column of type NVARCHAR(MAX):
CREATE TABLE MyTable (
    Id INT PRIMARY KEY,
    Name NVARCHAR(MAX),
    Description NVARCHAR(MAX)
);
In this example: - MyTable is the name of the table. - Id is defined as an INT column that serves as the primary key. - Name is an NVARCHAR(MAX) column for storing a name. - Description is another NVARCHAR(MAX) column for storing a description. You can customize the column names and add any additional columns as needed for your specific use case.