Home > Archive > MS SQL Server > April 2005 > Add Formula for a column









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Add Formula for a column
Calvin

2005-04-29, 3:23 am

I'm trying to add a formula to a column in a Table, in Enterprise Manager,
but I'm not being allowed.

I want a column to be multiplication of two other columns, datatypes money
and decimal.

I'm typing SubTotal * TaxRate ....

What's the big deal with this?


Chandra

2005-04-29, 3:23 am

Hi Calvin
As per my knowledge you cannot add formula to the table. You can do this in
your query.

If u feel you use the formula frequently, u can create a VIEW of UDF

Hope this will solve your problem.

Thanks and regards
Chandra


"Calvin" wrote:

> I'm trying to add a formula to a column in a Table, in Enterprise Manager,
> but I'm not being allowed.
>
> I want a column to be multiplication of two other columns, datatypes money
> and decimal.
>
> I'm typing SubTotal * TaxRate ....
>
> What's the big deal with this?
>
>
>

Tibor Karaszi

2005-04-29, 3:23 am

Try using Query Analyzer and execute the CREATE TABLE statement instead, then you can post an error
message for us. Below work fine on my machine:

CREATE TABLE #t
(subtotal decimal(5,3)
,taxrate int
,x AS subtotal*taxrate)

An alternative is to present derived information in views instead of in the table...

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/



"Calvin" <calvin@discussions.microsoft.com> wrote in message
news:BE975F7D. 1622%calvin@discussi
ons.microsoft.com...
> I'm trying to add a formula to a column in a Table, in Enterprise Manager,
> but I'm not being allowed.
>
> I want a column to be multiplication of two other columns, datatypes money
> and decimal.
>
> I'm typing SubTotal * TaxRate ....
>
> What's the big deal with this?
>
>



Calvin

2005-04-29, 9:23 am

Yeah... realized that would save the hassle after my post. Thanks for your
reply.


On 29/4/05 7:06 am, in article
5042C552-DDBF-4D63-BE77- C8B6ECDAF946@microso
ft.com, "Chandra"
<Chandra@discussions.microsoft.com> wrote:
[color=darkred]
> Hi Calvin
> As per my knowledge you cannot add formula to the table. You can do this in
> your query.
>
> If u feel you use the formula frequently, u can create a VIEW of UDF
>
> Hope this will solve your problem.
>
> Thanks and regards
> Chandra
>
>
> "Calvin" wrote:
>

Calvin

2005-04-29, 9:23 am

Decided to change the query which updates the table instead, but thanks fr
your reply.


On 29/4/05 9:19 am, in article O6qYcQJTFHA.3056@TK2MSFTNGP14.phx.gbl, "Tibor
Karaszi" <tibor_please.no. email_karaszi@hotmai
l.nomail.com> wrote:

> Try using Query Analyzer and execute the CREATE TABLE statement instead, then
> you can post an error
> message for us. Below work fine on my machine:
>
> CREATE TABLE #t
> (subtotal decimal(5,3)
> ,taxrate int
> ,x AS subtotal*taxrate)
>
> An alternative is to present derived information in views instead of in the
> table...


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com