在特定列上设置ANSI_PADDING(同一表的不同列中的ANSI_PADDING ON和OFF) [英] Set ANSI_PADDING on a specific column (ANSI_PADDING ON and OFF in different columns of the same table)

查看:619
本文介绍了在特定列上设置ANSI_PADDING(同一表的不同列中的ANSI_PADDING ON和OFF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以-使用单个CREATE TABLE脚本-设置特定的 varbinary ANSI_PADDING = ON ,但其他到 ANSI_PADDING = OFF

Is it possible - using a single CREATE TABLE script - to set specific varbinary columns ANSI_PADDING = ON but others to ANSI_PADDING = OFF?

例如

CREATE TABLE PaddingX (
    ...
    ColumnA varbinary(max),
    ...    
    ColumnB varbinary(50)
)

我想要 ColumnA 进行修剪(填充 OFF ),但 ColumnB 包含完整(填充)值-填充 ON

I would like ColumnA to trim (padding OFF), but ColumnB to contain the full (padded) value - padding ON.

推荐答案

分两步来完成它:

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 ANDI passing

这是唯一的方法。

如果您查看设置ANSI_PADDING文档,您可以阅读:

If you look at the remarks of SET ANSI_PADDING docs, you can read:


此设置仅影响新列的定义。创建列后,SQL Server将基于创建列时的设置存储值。现有列不受此设置的以后更改的影响。

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.

注意:要添加新列,您可以参见A示例 ALTER TABLE文档

NOTE: for adding new columns, you can see the A Example of ALTER TABLE docs.

这篇关于在特定列上设置ANSI_PADDING(同一表的不同列中的ANSI_PADDING ON和OFF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆