是否可以 - 使用单个 CREATE TABLE 脚本 - 将特定的 varbinary
列 ANSI_PADDING = ON
设置为 ANSI_PADDING = ON
,而将其他列设置为 ANSI_PADDING = OFF
?
例如
CREATE TABLE PaddingX (
...
ColumnA varbinary(max),
...
ColumnB varbinary(50)
)
我希望 ColumnA
进行修剪(填充 OFF
),但 ColumnB
包含完整(填充的)值 - 填充 开
。
最佳答案
您必须分两步完成:
SET ANSI_PADDING OFF
-- create the table without the columns that need ANSI padding
SET ANSI_PADDING ON
-- alter the table to add the columns that need ANSI padding
这是唯一的方法。
如果你看SET ANSI_PADDING docs的言论,您可以阅读:
This setting affects only the definition of new columns. After the column is created, SQL Server stores the values based on the setting when the column was created. Existing columns are not affected by a later change to this setting.
注意:要添加新列,您可以查看 ALTER TABLE docs 的示例.
关于sql - 在特定列上设置 ANSI_PADDING(同一表的不同列中 ANSI_PADDING ON 和 OFF),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28668954/