Tuesday, August 7, 2018

use COLLATE when doing a CREATE TABLE in T-SQL to specify a culture at a particular column to be

CREATE TABLE Cat
(
   CatId INT NOT NULL IDENTITY,
   Name VARCHAR(50) COLLATE Latin1_General_CI_AS,
   Gender CHAR(1) COLLATE Latin1_General_CI_AS,
   LivesLeft INT,
   CONSTRAINT PK_Cat PRIMARY KEY (CatId)
);

 
 

Note that, per this, CHAR and NCHAR are fixed widths, exactly n long, and VARCHAR and NVARCHAR are of variable lengths, up to n long. CHAR and VARCHAR cannot handle Unicode characters while NCHAR and NVARCHAR may.

No comments:

Post a Comment