>>Hi,
>>
>>What is the syntax of adding a placeholder-column to a cursor that would allow NULLs?
>>
>>Here is the code:
>>
>>
>>select MYTABLE.*, CAST(0 AS INT) AS MyField1 FROM MYTABLE
>>
>>
>>I need to make sure that the column MyField1 would accept NULLs. How do I do it? TIA.
>
>This works
>
>
>select CAST(coalesce(null,0) as int) as NewColumn
>into #NewTable
>
>insert into #NewTable values (null)
>select * from #NewTable
>
>
>In other words, the trick seems in using COALESCE function.
>
>The idea is from
>
http://stackoverflow.com/questions/5465245/create-a-nullable-column-using-sql-server-select-intoNever mind, it's important to put NULL first in the COALESCE.
If it's not broken, fix it until it is.
My Blog