这是我到目前为止的DDL。但现在我意识到在填充表格后需要存储大写字母ascii的数据。
CREATE TABLE [dbo].[Phrase]
(
[PhraseId] UNIQUEIDENTIFIER DEFAULT (newid()) NOT NULL,
[English] NVARCHAR (MAX) NOT NULL,
[EnglishAscii] AS (ascii([English])) PERSISTED,
PRIMARY KEY CLUSTERED ([PhraseId] ASC))
);
有人可以告诉我,我是否可以更改EnglishAscii
列以存储大写[English]
列的ascii值,并且我可以更改表格而无需放下并重新创建它?
答案 0 :(得分:3)
将英语列更改为UPPER
个案,然后找到ASCII
值
试试这个
CREATE TABLE [dbo].[Phrase] (
[PhraseId] UNIQUEIDENTIFIER DEFAULT (newid()) NOT NULL,
[English] NVARCHAR (MAX) NOT NULL,
[EnglishAscii] AS (ascii(UPPER([English]))) PERSISTED,
PRIMARY KEY CLUSTERED ([PhraseId] ASC)
);
如果要更改现有的Computed列,则必须删除计算列并重新创建
ALTER TABLE dbo.Phrase
DROP COLUMN EnglishAscii
ALTER TABLE dbo.Phrase
ADD EnglishAscii AS (ascii(UPPER([English]))) PERSISTED