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
 Other Forums
 MS Access
 Assign a value to a field based on the value in another field in a user defined function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-02 : 09:28:39
Bob writes "In access it is possible to use the iif() function in a query to test for the value of a field, assign a value to that field according to the value return from the iif() function.

I am looking for the same functionality in SQL Server. Heres my example

I have three field that make up an equipment number

Unit_Type = AHU
Bldg_Id = TD
Unit_No = 01

in a view you can do this
Unit_Type + "-" + Bldg_Id + "-" + Unit_No As Equip_No

now Equip_No = AHU-TD-01

In some cases the Bldg_Id field is not filled out and the Equip_No should read AHU-01. However in a view you cannot test for the value of Bldg_ID and Equip_No would equal AHU--01 (notice the two dashes)

So my question is this... Is there a way in a user function to test for the value of the Bldg_Id field, if it is null make Equip_No AHU-01 instead of AHU--01. I would then want to use this as the recordsource for a view?

Thank you so much for your time"
   

- Advertisement -