Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Set empty field value to NULL
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01640098
Message ID:
01640104
Vues:
37
>>>>Hi,
>>>>
>>>>Is it possible to change some property of a field/column in a SQL Database that automatically sets the value to NULL if the value is an empty string? That is, the application may update the value of a column to an empty string but I want the SQL to set it as NULL.
>>>>
>>>>TIA
>>>
>>>This can be done through a trigger. Simple AFTER UPDATE/INSERT trigger can do that.
>>
>>I will check out how to do it. Thanks.
>
>create trigger trMyTableMyColumnChange after insert, update
>as
>
>update myTable set myColumn = null
>from myTable inner join Inserted I on myTable.PK = Inserted.PK
>where I.myColumn = ''

Thank you!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform