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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Irritating Update question

Author  Topic 

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2008-10-10 : 09:26:09
I have a table with a column 'DebtTypeCode' of type varchar(8)

Currently this column is null for all rows. I wish to make it an empty string. But using

USE debt
UPDATE table Debt
SET DebtTypeCode = ""
WHERE DebtTypeCode ISNULL

leaves the column as null for all rows.

Where am I going wrong please?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-10 : 09:30:00
quote:
Originally posted by OldMySQLUser

I have a table with a column 'DebtTypeCode' of type varchar(8)

Currently this column is null for all rows. I wish to make it an empty string. But using

USE debt
UPDATE table Debt
SET DebtTypeCode = ""
WHERE DebtTypeCode IS NULL
leaves the column as null for all rows.

Where am I going wrong please?


use IS NULL instead of ISNULL.
IS NULL does comaprison with NULL values while ISNULL() functions replaces NULLs with specified value.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-10 : 10:53:12
quote:
Originally posted by OldMySQLUser

I have a table with a column 'DebtTypeCode' of type varchar(8)

Currently this column is null for all rows. I wish to make it an empty string. But using

USE debt
UPDATE table Debt
SET DebtTypeCode = ""
WHERE DebtTypeCode ISNULL

leaves the column as null for all rows.

Where am I going wrong please?


Where did you execute the code?
If you executed in QA, you would have got error

Madhivanan

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

- Advertisement -