I am noticing that when I use this statement, the Action
column is not nullable:
SELECT TOP 0 SerialNumber, 0 [Action] INTO #MyTable FROM FSE_Se
It looks like a definitive answer is here. Copying 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.
So, it looks like you are safe to use your CAST expression.