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 2000 Forums
 Transact-SQL (2000)
 View

Author  Topic 

maevr
Posting Yak Master

169 Posts

Posted - 2007-04-18 : 03:05:42
The table below hosts default values that are being used by an view to set a value in a column. If value is 0 then the column gets "Text1", this works for all but if there is NULL then the column does not get the default value it is going to.

create table ss1_uppmatvardelista
(
uppmatkod varchar(15) not null,
value decimal(14,4) null,
description varchar(50) not null
)

Default values are: 0 = "text1", 1 = "text2", 3 = text3

Query below checks the value in the column and updates the view

(select description as test from ss1_uppmatvardelista where value = UPPMAT_ISOLFANGTYP_LBN and uppmatkod = 'ISOLFANGTYP') from dbo.SS1_OLJA1

Any ideá how to handle the NULL value and values that does not exists in the ss1_uppmatvardelista?

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-04-18 : 11:09:13
Use the coalesce function, like this

coalesce(value, 0)

That will return value if it is not null, but it will return 0 if value is null.
Go to Top of Page
   

- Advertisement -