- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我注意到当我使用这个语句时,Action
列不可为空:
SELECT TOP 0 SerialNumber, 0 [Action] INTO #MyTable FROM FSE_SerialNumber
Action
列可以为空:
SELECT TOP 0 SerialNumber, CAST(0 as int) [Action] INTO #MyTable FROM FSE_SerialNumber
最佳答案
看起来确定的答案是 here .复制到这里:
Metadata is determined based on the source column and expressions used in the SELECT list. Below are the rules:
Any expression that uses a built-in function like SUBSTRING, LEFT, RIGHT etc (except ISNULL) for example is considered as NULLable by the engine. So if you use CAST(somecol as char(8)) then the expression is NULLable
Literals, constants, global variables like @@DBTS, @@ERROR etc are considered non-NULLable since they return some value always
If expression is a column then nullability is derived from the source column metadata
So to make an expression or column in the SELECT list not null then use ISNULL around the column or expression.
关于sql - 如何在 SELECT INTO 中控制基于文字的列的可空性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11872106/
我是一名优秀的程序员,十分优秀!