Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to set a field value to null

Author  Topic 

Pasi
Posting Yak Master

166 Posts

Posted - 2014-03-26 : 19:35:44
HI,

I have a column called person.last_name, and I want to set this field to NULL if person.last_name ='test'
I have tried this but don't work:
ISNULL({person.last_name},'<>"test'))

Thanks!

nagino
Yak Posting Veteran

75 Posts

Posted - 2014-03-26 : 19:52:59
UPDATE person SET last_name = null WHERE last_name = 'test'

-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-03-26 : 22:47:31
Thanks Nagino but this is not what I am looking for , I don't want to update or overwrite a table in sql I ma accessing the SQl from my app and want to write the formula to say if the column has "test" in it, ignore it or set it to null. looking for formula to do the condition for me.
Pasi
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-26 : 23:14:23
[code]NULLIF ( person.last_name , 'test' )[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-03-27 : 01:16:36
Thanks! hope this works.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-27 : 01:26:15
keep your finger cross


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-03-28 : 06:04:56
or


case when person.last_name = 'test' then NULL else person.last_name end


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-04-02 : 14:47:16
Thanks Madhivanan I will try that!
Pasi
Go to Top of Page
   

- Advertisement -