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)
 A View Or a Stored Procedure?

Author  Topic 

yuryn1961
Starting Member

3 Posts

Posted - 2008-04-21 : 04:39:21
Hello,

I've got a table [CUSTOMERS] with two fields (actually more, but it doesn't matter for my question):
[CUST_NAME_EN], [CUST_NAME_RU].
[CUST_NAME_EN] is mandatory.
My task is to get a recordset with [CUST_NAME_RU] AS CUST_NAME value IF IT IS NOT NULL, BLANK OR EMPTY. Otherwise, it must be [CUST_NAME_EN] AS CUST_NAME.

Should I solve this problem with a view or a stored procedure? I'm not an SQL-programmer, so would somebody be kind to help?

Thank you.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-21 : 04:49:38
1. If this is the only thing you want to do in a query and,
2. this is the only query and,
3. this query is being used repetitively,

then you can encapsulate this query in a view.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-21 : 04:56:07
SELECT COALESCE(NULLIF(CUST_NAME_RU, ''), CUST_NAME_EN) AS CUST_NAME
FROM [CUSTOMERS]



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

yuryn1961
Starting Member

3 Posts

Posted - 2008-04-21 : 04:59:03
Thank You very much, Peso!
Go to Top of Page
   

- Advertisement -