Home All Groups Group Topic Archive Search About

Q: DataColumn Expressions

Author
13 Dec 2006 5:29 PM
G .Net
Hi

Can anybody help with a problem with Expressions for DataColumns

Suppose I have a table with three fields A, B and C.

I want an expression in column C so that

C = 2 * A if A is not null
C = 3 * B otherwise

Can anybody help with the syntax?

Thanks in advance

G

Author
13 Dec 2006 11:57 PM
RobinS
I'm not sure what you mean "Expressions for DataColumns".

If you mean in a query, try using an IIF statement.

Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
  FROM ...

Is that what you were looking for?

Robin S.
--------------------
Show quoteHide quote
"G .Net" <nodamnspam@email.com> wrote in message
news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
> Hi
>
> Can anybody help with a problem with Expressions for DataColumns
>
> Suppose I have a table with three fields A, B and C.
>
> I want an expression in column C so that
>
> C = 2 * A if A is not null
> C = 3 * B otherwise
>
> Can anybody help with the syntax?
>
> Thanks in advance
>
> G
>
Author
14 Dec 2006 4:19 AM
Stephany Young
No. The OP means "Expressions for DataColumns".

  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)

Because you are doing multiplication on either A or B then both A (if it is
not null) and B must be numeric, therefore you must use some non-conflicting
token to indicate a psuedo-value for A ('Z').

This is because IsNull(expression, replacementvalue) returns either the
value for A (if it is not null) or the specified replacement value (if it is
null). You can't use to return some other conditional value.

You then convert the result (which will either be a numeric or 'Z') to a
string and use an equality comparison of that against 'Z' in the IIF() which
now allows you to return 3* B on true (A is null) or 2 * A on false (A is
not null).

It might seem strange to convert 'Z' to a string seeing as it already is a
string, but you need to remember that the result of the IsNull() may be
numeric.

All this assumes, of course, that B must never be null.

If B is allowed to be null then you need to re-work the true part of the
IIF() to ensure that it will always be evaluatable.


Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
> I'm not sure what you mean "Expressions for DataColumns".
>
> If you mean in a query, try using an IIF statement.
>
> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>  FROM ...
>
> Is that what you were looking for?
>
> Robin S.
> --------------------
> "G .Net" <nodamnspam@email.com> wrote in message
> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>> Hi
>>
>> Can anybody help with a problem with Expressions for DataColumns
>>
>> Suppose I have a table with three fields A, B and C.
>>
>> I want an expression in column C so that
>>
>> C = 2 * A if A is not null
>> C = 3 * B otherwise
>>
>> Can anybody help with the syntax?
>>
>> Thanks in advance
>>
>> G
>>
>
>
Author
14 Dec 2006 6:04 AM
RobinS
So is this something that would be part of a query? Or
to define a datacolumn in a dataset? Since apparently
I missed the boat with my answer, can you tell me what
this is used for? I'd appreciate it; I'm always looking
to learn something new.

Thanks,
Robin S.
------------------------------------
Show quoteHide quote
"Stephany Young" <noone@localhost> wrote in message
news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
> No. The OP means "Expressions for DataColumns".
>
>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)
>
> Because you are doing multiplication on either A or B then both A (if
> it is not null) and B must be numeric, therefore you must use some
> non-conflicting token to indicate a psuedo-value for A ('Z').
>
> This is because IsNull(expression, replacementvalue) returns either
> the value for A (if it is not null) or the specified replacement value
> (if it is null). You can't use to return some other conditional value.
>
> You then convert the result (which will either be a numeric or 'Z') to
> a string and use an equality comparison of that against 'Z' in the
> IIF() which now allows you to return 3* B on true (A is null) or 2 * A
> on false (A is not null).
>
> It might seem strange to convert 'Z' to a string seeing as it already
> is a string, but you need to remember that the result of the IsNull()
> may be numeric.
>
> All this assumes, of course, that B must never be null.
>
> If B is allowed to be null then you need to re-work the true part of
> the IIF() to ensure that it will always be evaluatable.
>
>
> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>> I'm not sure what you mean "Expressions for DataColumns".
>>
>> If you mean in a query, try using an IIF statement.
>>
>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>  FROM ...
>>
>> Is that what you were looking for?
>>
>> Robin S.
>> --------------------
>> "G .Net" <nodamnspam@email.com> wrote in message
>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>> Hi
>>>
>>> Can anybody help with a problem with Expressions for DataColumns
>>>
>>> Suppose I have a table with three fields A, B and C.
>>>
>>> I want an expression in column C so that
>>>
>>> C = 2 * A if A is not null
>>> C = 3 * B otherwise
>>>
>>> Can anybody help with the syntax?
>>>
>>> Thanks in advance
>>>
>>> G
>>>
>>
>>
>
>
Author
14 Dec 2006 6:55 AM
Stephany Young
F1 ... DataColumn ... Members ... Expression


Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:66adnb6JjfrIdB3YnZ2dnUVZ_v2nnZ2d@comcast.com...
> So is this something that would be part of a query? Or
> to define a datacolumn in a dataset? Since apparently
> I missed the boat with my answer, can you tell me what
> this is used for? I'd appreciate it; I'm always looking
> to learn something new.
>
> Thanks,
> Robin S.
> ------------------------------------
> "Stephany Young" <noone@localhost> wrote in message
> news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
>> No. The OP means "Expressions for DataColumns".
>>
>>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)
>>
>> Because you are doing multiplication on either A or B then both A (if it
>> is not null) and B must be numeric, therefore you must use some
>> non-conflicting token to indicate a psuedo-value for A ('Z').
>>
>> This is because IsNull(expression, replacementvalue) returns either the
>> value for A (if it is not null) or the specified replacement value (if it
>> is null). You can't use to return some other conditional value.
>>
>> You then convert the result (which will either be a numeric or 'Z') to a
>> string and use an equality comparison of that against 'Z' in the IIF()
>> which now allows you to return 3* B on true (A is null) or 2 * A on false
>> (A is not null).
>>
>> It might seem strange to convert 'Z' to a string seeing as it already is
>> a string, but you need to remember that the result of the IsNull() may be
>> numeric.
>>
>> All this assumes, of course, that B must never be null.
>>
>> If B is allowed to be null then you need to re-work the true part of the
>> IIF() to ensure that it will always be evaluatable.
>>
>>
>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>>> I'm not sure what you mean "Expressions for DataColumns".
>>>
>>> If you mean in a query, try using an IIF statement.
>>>
>>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>>  FROM ...
>>>
>>> Is that what you were looking for?
>>>
>>> Robin S.
>>> --------------------
>>> "G .Net" <nodamnspam@email.com> wrote in message
>>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>>> Hi
>>>>
>>>> Can anybody help with a problem with Expressions for DataColumns
>>>>
>>>> Suppose I have a table with three fields A, B and C.
>>>>
>>>> I want an expression in column C so that
>>>>
>>>> C = 2 * A if A is not null
>>>> C = 3 * B otherwise
>>>>
>>>> Can anybody help with the syntax?
>>>>
>>>> Thanks in advance
>>>>
>>>> G
>>>>
>>>
>>>
>>
>>
>
>
Author
14 Dec 2006 7:38 AM
G .Net
Thanks guys; actually Robin asnwered the question with his first response.

Merry Christmas!

G

Show quoteHide quote
"Stephany Young" <noone@localhost> wrote in message
news:%23RhRJz0HHHA.420@TK2MSFTNGP02.phx.gbl...
> F1 ... DataColumn ... Members ... Expression
>
>
> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
> news:66adnb6JjfrIdB3YnZ2dnUVZ_v2nnZ2d@comcast.com...
>> So is this something that would be part of a query? Or
>> to define a datacolumn in a dataset? Since apparently
>> I missed the boat with my answer, can you tell me what
>> this is used for? I'd appreciate it; I'm always looking
>> to learn something new.
>>
>> Thanks,
>> Robin S.
>> ------------------------------------
>> "Stephany Young" <noone@localhost> wrote in message
>> news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
>>> No. The OP means "Expressions for DataColumns".
>>>
>>>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)
>>>
>>> Because you are doing multiplication on either A or B then both A (if it
>>> is not null) and B must be numeric, therefore you must use some
>>> non-conflicting token to indicate a psuedo-value for A ('Z').
>>>
>>> This is because IsNull(expression, replacementvalue) returns either the
>>> value for A (if it is not null) or the specified replacement value (if
>>> it is null). You can't use to return some other conditional value.
>>>
>>> You then convert the result (which will either be a numeric or 'Z') to a
>>> string and use an equality comparison of that against 'Z' in the IIF()
>>> which now allows you to return 3* B on true (A is null) or 2 * A on
>>> false (A is not null).
>>>
>>> It might seem strange to convert 'Z' to a string seeing as it already is
>>> a string, but you need to remember that the result of the IsNull() may
>>> be numeric.
>>>
>>> All this assumes, of course, that B must never be null.
>>>
>>> If B is allowed to be null then you need to re-work the true part of the
>>> IIF() to ensure that it will always be evaluatable.
>>>
>>>
>>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>>> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>>>> I'm not sure what you mean "Expressions for DataColumns".
>>>>
>>>> If you mean in a query, try using an IIF statement.
>>>>
>>>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>>>  FROM ...
>>>>
>>>> Is that what you were looking for?
>>>>
>>>> Robin S.
>>>> --------------------
>>>> "G .Net" <nodamnspam@email.com> wrote in message
>>>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>>>> Hi
>>>>>
>>>>> Can anybody help with a problem with Expressions for DataColumns
>>>>>
>>>>> Suppose I have a table with three fields A, B and C.
>>>>>
>>>>> I want an expression in column C so that
>>>>>
>>>>> C = 2 * A if A is not null
>>>>> C = 3 * B otherwise
>>>>>
>>>>> Can anybody help with the syntax?
>>>>>
>>>>> Thanks in advance
>>>>>
>>>>> G
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
14 Dec 2006 8:31 AM
RobinS
I'm glad I could help. You have a merry Christmas too!

Robin S.
------------------
Show quoteHide quote
"G .Net" <nodamnspam@email.com> wrote in message
news:tt6dneer_MrkYh3YnZ2dnUVZ8ta3nZ2d@pipex.net...
> Thanks guys; actually Robin asnwered the question with his first
> response.
>
> Merry Christmas!
>
> G
>
> "Stephany Young" <noone@localhost> wrote in message
> news:%23RhRJz0HHHA.420@TK2MSFTNGP02.phx.gbl...
>> F1 ... DataColumn ... Members ... Expression
>>
>>
>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>> news:66adnb6JjfrIdB3YnZ2dnUVZ_v2nnZ2d@comcast.com...
>>> So is this something that would be part of a query? Or
>>> to define a datacolumn in a dataset? Since apparently
>>> I missed the boat with my answer, can you tell me what
>>> this is used for? I'd appreciate it; I'm always looking
>>> to learn something new.
>>>
>>> Thanks,
>>> Robin S.
>>> ------------------------------------
>>> "Stephany Young" <noone@localhost> wrote in message
>>> news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
>>>> No. The OP means "Expressions for DataColumns".
>>>>
>>>>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)
>>>>
>>>> Because you are doing multiplication on either A or B then both A
>>>> (if it is not null) and B must be numeric, therefore you must use
>>>> some non-conflicting token to indicate a psuedo-value for A ('Z').
>>>>
>>>> This is because IsNull(expression, replacementvalue) returns either
>>>> the value for A (if it is not null) or the specified replacement
>>>> value (if it is null). You can't use to return some other
>>>> conditional value.
>>>>
>>>> You then convert the result (which will either be a numeric or 'Z')
>>>> to a string and use an equality comparison of that against 'Z' in
>>>> the IIF() which now allows you to return 3* B on true (A is null)
>>>> or 2 * A on false (A is not null).
>>>>
>>>> It might seem strange to convert 'Z' to a string seeing as it
>>>> already is a string, but you need to remember that the result of
>>>> the IsNull() may be numeric.
>>>>
>>>> All this assumes, of course, that B must never be null.
>>>>
>>>> If B is allowed to be null then you need to re-work the true part
>>>> of the IIF() to ensure that it will always be evaluatable.
>>>>
>>>>
>>>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>>>> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>>>>> I'm not sure what you mean "Expressions for DataColumns".
>>>>>
>>>>> If you mean in a query, try using an IIF statement.
>>>>>
>>>>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>>>>  FROM ...
>>>>>
>>>>> Is that what you were looking for?
>>>>>
>>>>> Robin S.
>>>>> --------------------
>>>>> "G .Net" <nodamnspam@email.com> wrote in message
>>>>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>>>>> Hi
>>>>>>
>>>>>> Can anybody help with a problem with Expressions for DataColumns
>>>>>>
>>>>>> Suppose I have a table with three fields A, B and C.
>>>>>>
>>>>>> I want an expression in column C so that
>>>>>>
>>>>>> C = 2 * A if A is not null
>>>>>> C = 3 * B otherwise
>>>>>>
>>>>>> Can anybody help with the syntax?
>>>>>>
>>>>>> Thanks in advance
>>>>>>
>>>>>> G
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
14 Dec 2006 8:30 AM
RobinS
Ouch!

I tried that before posting the question back, but asked
for "expressions datacolumns" instead of "datacolumns
expressions" and got a bunch of stuff about Reporting
Services in SQLServer and MDX and XQuery and using
expressions instead of Triggers and Expressions
in TransactSQL.

I couldn't get anything out of MSDN (seems to be having a
problem).

That's the only reason I posted the question. I figured
some kind soul would give me a one-liner or just a "yes
no yes" answer to my q's. I didn't realize it would be
so much trouble. When I go back and search on the keywords
in the reverse order, I get more information. So never mind.

Have a nice day.
Robin S.
-----------------------
Show quoteHide quote
"Stephany Young" <noone@localhost> wrote in message
news:%23RhRJz0HHHA.420@TK2MSFTNGP02.phx.gbl...
> F1 ... DataColumn ... Members ... Expression
>
>
> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
> news:66adnb6JjfrIdB3YnZ2dnUVZ_v2nnZ2d@comcast.com...
>> So is this something that would be part of a query? Or
>> to define a datacolumn in a dataset? Since apparently
>> I missed the boat with my answer, can you tell me what
>> this is used for? I'd appreciate it; I'm always looking
>> to learn something new.
>>
>> Thanks,
>> Robin S.
>> ------------------------------------
>> "Stephany Young" <noone@localhost> wrote in message
>> news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
>>> No. The OP means "Expressions for DataColumns".
>>>
>>>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)
>>>
>>> Because you are doing multiplication on either A or B then both A
>>> (if it is not null) and B must be numeric, therefore you must use
>>> some non-conflicting token to indicate a psuedo-value for A ('Z').
>>>
>>> This is because IsNull(expression, replacementvalue) returns either
>>> the value for A (if it is not null) or the specified replacement
>>> value (if it is null). You can't use to return some other
>>> conditional value.
>>>
>>> You then convert the result (which will either be a numeric or 'Z')
>>> to a string and use an equality comparison of that against 'Z' in
>>> the IIF() which now allows you to return 3* B on true (A is null) or
>>> 2 * A on false (A is not null).
>>>
>>> It might seem strange to convert 'Z' to a string seeing as it
>>> already is a string, but you need to remember that the result of the
>>> IsNull() may be numeric.
>>>
>>> All this assumes, of course, that B must never be null.
>>>
>>> If B is allowed to be null then you need to re-work the true part of
>>> the IIF() to ensure that it will always be evaluatable.
>>>
>>>
>>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>>> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>>>> I'm not sure what you mean "Expressions for DataColumns".
>>>>
>>>> If you mean in a query, try using an IIF statement.
>>>>
>>>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>>>  FROM ...
>>>>
>>>> Is that what you were looking for?
>>>>
>>>> Robin S.
>>>> --------------------
>>>> "G .Net" <nodamnspam@email.com> wrote in message
>>>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>>>> Hi
>>>>>
>>>>> Can anybody help with a problem with Expressions for DataColumns
>>>>>
>>>>> Suppose I have a table with three fields A, B and C.
>>>>>
>>>>> I want an expression in column C so that
>>>>>
>>>>> C = 2 * A if A is not null
>>>>> C = 3 * B otherwise
>>>>>
>>>>> Can anybody help with the syntax?
>>>>>
>>>>> Thanks in advance
>>>>>
>>>>> G
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
14 Dec 2006 9:03 AM
Stephany Young
As you can now see, the subject is very complex and there is no way that I
was going to regurgitate what it in here because it is is far better that
you read it in it's context.


Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:6N2dnZ4Uu_EolhzYnZ2dnUVZ_sapnZ2d@comcast.com...
> Ouch!
>
> I tried that before posting the question back, but asked
> for "expressions datacolumns" instead of "datacolumns
> expressions" and got a bunch of stuff about Reporting
> Services in SQLServer and MDX and XQuery and using
> expressions instead of Triggers and Expressions
> in TransactSQL.
>
> I couldn't get anything out of MSDN (seems to be having a
> problem).
>
> That's the only reason I posted the question. I figured
> some kind soul would give me a one-liner or just a "yes
> no yes" answer to my q's. I didn't realize it would be
> so much trouble. When I go back and search on the keywords
> in the reverse order, I get more information. So never mind.
>
> Have a nice day.
> Robin S.
> -----------------------
> "Stephany Young" <noone@localhost> wrote in message
> news:%23RhRJz0HHHA.420@TK2MSFTNGP02.phx.gbl...
>> F1 ... DataColumn ... Members ... Expression
>>
>>
>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>> news:66adnb6JjfrIdB3YnZ2dnUVZ_v2nnZ2d@comcast.com...
>>> So is this something that would be part of a query? Or
>>> to define a datacolumn in a dataset? Since apparently
>>> I missed the boat with my answer, can you tell me what
>>> this is used for? I'd appreciate it; I'm always looking
>>> to learn something new.
>>>
>>> Thanks,
>>> Robin S.
>>> ------------------------------------
>>> "Stephany Young" <noone@localhost> wrote in message
>>> news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
>>>> No. The OP means "Expressions for DataColumns".
>>>>
>>>>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 * A)
>>>>
>>>> Because you are doing multiplication on either A or B then both A (if
>>>> it is not null) and B must be numeric, therefore you must use some
>>>> non-conflicting token to indicate a psuedo-value for A ('Z').
>>>>
>>>> This is because IsNull(expression, replacementvalue) returns either the
>>>> value for A (if it is not null) or the specified replacement value (if
>>>> it is null). You can't use to return some other conditional value.
>>>>
>>>> You then convert the result (which will either be a numeric or 'Z') to
>>>> a string and use an equality comparison of that against 'Z' in the
>>>> IIF() which now allows you to return 3* B on true (A is null) or 2 * A
>>>> on false (A is not null).
>>>>
>>>> It might seem strange to convert 'Z' to a string seeing as it already
>>>> is a string, but you need to remember that the result of the IsNull()
>>>> may be numeric.
>>>>
>>>> All this assumes, of course, that B must never be null.
>>>>
>>>> If B is allowed to be null then you need to re-work the true part of
>>>> the IIF() to ensure that it will always be evaluatable.
>>>>
>>>>
>>>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>>>> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>>>>> I'm not sure what you mean "Expressions for DataColumns".
>>>>>
>>>>> If you mean in a query, try using an IIF statement.
>>>>>
>>>>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>>>>  FROM ...
>>>>>
>>>>> Is that what you were looking for?
>>>>>
>>>>> Robin S.
>>>>> --------------------
>>>>> "G .Net" <nodamnspam@email.com> wrote in message
>>>>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>>>>> Hi
>>>>>>
>>>>>> Can anybody help with a problem with Expressions for DataColumns
>>>>>>
>>>>>> Suppose I have a table with three fields A, B and C.
>>>>>>
>>>>>> I want an expression in column C so that
>>>>>>
>>>>>> C = 2 * A if A is not null
>>>>>> C = 3 * B otherwise
>>>>>>
>>>>>> Can anybody help with the syntax?
>>>>>>
>>>>>> Thanks in advance
>>>>>>
>>>>>> G
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
14 Dec 2006 4:48 PM
RobinS
Fair enough. It didn't occur to me to reverse the search
parameters. I keep forgetting that MS isn't as good at
searching as Google. Silly me!

Robin S.
------------------------------
Show quoteHide quote
"Stephany Young" <noone@localhost> wrote in message
news:uyGUs61HHHA.4992@TK2MSFTNGP04.phx.gbl...
> As you can now see, the subject is very complex and there is no way
> that I was going to regurgitate what it in here because it is is far
> better that you read it in it's context.
>
>
> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
> news:6N2dnZ4Uu_EolhzYnZ2dnUVZ_sapnZ2d@comcast.com...
>> Ouch!
>>
>> I tried that before posting the question back, but asked
>> for "expressions datacolumns" instead of "datacolumns
>> expressions" and got a bunch of stuff about Reporting
>> Services in SQLServer and MDX and XQuery and using
>> expressions instead of Triggers and Expressions
>> in TransactSQL.
>>
>> I couldn't get anything out of MSDN (seems to be having a
>> problem).
>>
>> That's the only reason I posted the question. I figured
>> some kind soul would give me a one-liner or just a "yes
>> no yes" answer to my q's. I didn't realize it would be
>> so much trouble. When I go back and search on the keywords
>> in the reverse order, I get more information. So never mind.
>>
>> Have a nice day.
>> Robin S.
>> -----------------------
>> "Stephany Young" <noone@localhost> wrote in message
>> news:%23RhRJz0HHHA.420@TK2MSFTNGP02.phx.gbl...
>>> F1 ... DataColumn ... Members ... Expression
>>>
>>>
>>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>>> news:66adnb6JjfrIdB3YnZ2dnUVZ_v2nnZ2d@comcast.com...
>>>> So is this something that would be part of a query? Or
>>>> to define a datacolumn in a dataset? Since apparently
>>>> I missed the boat with my answer, can you tell me what
>>>> this is used for? I'd appreciate it; I'm always looking
>>>> to learn something new.
>>>>
>>>> Thanks,
>>>> Robin S.
>>>> ------------------------------------
>>>> "Stephany Young" <noone@localhost> wrote in message
>>>> news:OxeCFczHHHA.4068@TK2MSFTNGP03.phx.gbl...
>>>>> No. The OP means "Expressions for DataColumns".
>>>>>
>>>>>  IIf(Convert(IsNull(A, 'Z'), 'System.String')) = 'Z', 3 * B, 2 *
>>>>> A)
>>>>>
>>>>> Because you are doing multiplication on either A or B then both A
>>>>> (if it is not null) and B must be numeric, therefore you must use
>>>>> some non-conflicting token to indicate a psuedo-value for A ('Z').
>>>>>
>>>>> This is because IsNull(expression, replacementvalue) returns
>>>>> either the value for A (if it is not null) or the specified
>>>>> replacement value (if it is null). You can't use to return some
>>>>> other conditional value.
>>>>>
>>>>> You then convert the result (which will either be a numeric or
>>>>> 'Z') to a string and use an equality comparison of that against
>>>>> 'Z' in the IIF() which now allows you to return 3* B on true (A is
>>>>> null) or 2 * A on false (A is not null).
>>>>>
>>>>> It might seem strange to convert 'Z' to a string seeing as it
>>>>> already is a string, but you need to remember that the result of
>>>>> the IsNull() may be numeric.
>>>>>
>>>>> All this assumes, of course, that B must never be null.
>>>>>
>>>>> If B is allowed to be null then you need to re-work the true part
>>>>> of the IIF() to ensure that it will always be evaluatable.
>>>>>
>>>>>
>>>>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
>>>>> news:zdCdnRjGw6rrDh3YnZ2dnUVZ_oernZ2d@comcast.com...
>>>>>> I'm not sure what you mean "Expressions for DataColumns".
>>>>>>
>>>>>> If you mean in a query, try using an IIF statement.
>>>>>>
>>>>>> Select A, B, IIF(A IS NULL, B * 3, A * 2) as C
>>>>>>  FROM ...
>>>>>>
>>>>>> Is that what you were looking for?
>>>>>>
>>>>>> Robin S.
>>>>>> --------------------
>>>>>> "G .Net" <nodamnspam@email.com> wrote in message
>>>>>> news:rpadnaJ-z5QFpR3YRVnyiQA@pipex.net...
>>>>>>> Hi
>>>>>>>
>>>>>>> Can anybody help with a problem with Expressions for DataColumns
>>>>>>>
>>>>>>> Suppose I have a table with three fields A, B and C.
>>>>>>>
>>>>>>> I want an expression in column C so that
>>>>>>>
>>>>>>> C = 2 * A if A is not null
>>>>>>> C = 3 * B otherwise
>>>>>>>
>>>>>>> Can anybody help with the syntax?
>>>>>>>
>>>>>>> Thanks in advance
>>>>>>>
>>>>>>> G
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>