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.
| Author |
Topic |
|
ronjohn
Starting Member
4 Posts |
Posted - 2010-07-31 : 18:51:05
|
| Can somebody tell me if I can do the following in sql:If (Column is null) Do somethingThanks, |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-08-01 : 02:42:23
|
| Yes it can be done.Example for you:declare @Test varchar(50)--Default value is null for @Testif @Test is null BeginPrint '@Test is null'--statements to be executed.EndElseBeginPrint '@Test is not null'--statements to be executed.EndRegards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
ronjohn
Starting Member
4 Posts |
Posted - 2010-08-01 : 20:50:18
|
| I've tried the following code and sql is telling me that rows are affected but when i look into the database all affected fields are still null.Here's the code:update Contactsset Title = ' 'where ListID = '9' and Fax is null |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-08-01 : 21:56:27
|
| you've updated TITLE based on FAX being null.Fax will still be null.If that doesn't help, give us a few sample records and the table definition, and what you hope to accomplish |
 |
|
|
|
|
|