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
 SQL Server Development (2000)
 multiple ISNULL check

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2006-10-11 : 02:53:12
Hi

I try to use this within a query...

(ISNULL(dbo.tbl_ShoppingCart.Att) AND ISNULL(dbo.tbl_ShoppingCart.Company)) AS NoAdress

But this doesen't work at all, could someone tell me how I should do this instead?

Regards

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-10-11 : 02:56:15
[code]
(ISNULL(dbo.tbl_ShoppingCart.Att) AND ISNULL(dbo.tbl_ShoppingCart.Company)) AS NoAdress
[/code]

which part of the query did you used this in?

if you want to use in the Select query then you dont require "AND", I guess you want to concancate the to string , then you "+" instead of And

[code]
(ISNULL(dbo.tbl_ShoppingCart.Att) +
ISNULL(dbo.tbl_ShoppingCart.Company)) AS NoAdress
[/code]

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-11 : 02:58:06
What are you trying to accomplish? The query above makes no sense.

1) Concatenating? -> ISNULL(dbo.tbl_ShoppingCart.Att, '') + ISNULL(dbo.tbl_ShoppingCart.Company, '') AS NoAdress
2) Filter out those records with no addresses? -> WHERE dbo.tbl_ShoppingCart.Att IS NULL AND dbo.tbl_ShoppingCart.Company IS NULL


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-11 : 02:58:46


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2006-10-11 : 03:07:54
Hi

I try to check 2 columns if they have null values and if so indicate this by setting the "NoAdress" column to 0. I dont want to filter out thoose rows that have null values, they have other information that I need to display but I need to check 2 columns for null values and indicate this in one column only.

Hope this make sence.

Regards
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-10-11 : 03:10:10
Somthing like this ?
ISNULL(dbo.tbl_ShoppingCart.Att,'0') +
ISNULL(dbo.tbl_ShoppingCart.Company,'0') AS NoAdress

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-11 : 03:28:17
Rather

SELECT CASE WHEN dbo.tbl_ShoppingCart.Att IS NULL AND dbo.tbl_ShoppingCart.Company IS NULL THEN 0
ELSE 1
END AS NoAddress
FROM YourTable


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2006-10-11 : 03:31:59
Hi Peter


That worked very well, Thank you so much!


Best Regards
Go to Top of Page
   

- Advertisement -