Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to add a column placeholder allow NULL
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01536981
Message ID:
01536994
Vues:
47
>>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-into


What is wrong with CAST(null as int)? Why the Coalesce is necessary?
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform