How to set sql server setting let to set null value when a empty string
(zero length) set to column?
I want it automatic to set null value when maintain data is a zero-length
string press to column of table. for example,
when a statement as "Insert into table1 values ('abc', '', '')' become to
save abc, null and null three values to table1.There is no such setting in SQL Server. You could create a trigger which per
forms this, but I would
look for some alternate options instead.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"ABC" <abc@.abc.com> wrote in message news:%230Fav01RGHA.2276@.tk2msftngp13.phx.gbl...darkred">
> How to set sql server setting let to set null value when a empty string (z
ero length) set to
> column?
> I want it automatic to set null value when maintain data is a zero-length
string press to column
> of table. for example,
> when a statement as "Insert into table1 values ('abc', '', '')' become to
save abc, null and null
> three values to table1.
>|||Would probaby have to create a trigger of the form (completely untested!)
CREATE TRIGGER NullifySomeEmptyStrings
ON table1
FOR AFTER INSERT, UPDATE
AS
--NULL out column2 if it now contains an empty string ''
IF UPDATE(column2)
BEGIN
UPDATE table1
SET column2 = NULL
WHERE table1.ThePrimaryKeyColumn IN
(SELECT ThePrimaryKeyColumn
FROM INSERTED
WHERE INSERTED.column2 = '')
END
"ABC" <abc@.abc.com> wrote in message
news:%230Fav01RGHA.2276@.tk2msftngp13.phx.gbl...
> How to set sql server setting let to set null value when a empty string
> (zero length) set to column?
> I want it automatic to set null value when maintain data is a zero-length
> string press to column of table. for example,
> when a statement as "Insert into table1 values ('abc', '', '')' become to
> save abc, null and null three values to table1.
>|||Why do you want it to be Null?
If you use Front End application, validate this and send valid data to
server
Madhivanan
Showing posts with label automatic. Show all posts
Showing posts with label automatic. Show all posts
Subscribe to:
Posts (Atom)