Monday, March 19, 2012

create rule

i have a table with two columns cust and price, i want to write a rule , the
value of price must be >= cust * 1,4 , the ideia is not permit write in
price a value minor of 40 % profit, how i can write this?
Thanks in advance
Alejandro CarneroThis can be implemented using a table level 'check constraint'.
"alejandro" <alecarnero@.uol.com.br> wrote in message
news:e1GydsEHGHA.2300@.TK2MSFTNGP15.phx.gbl...
>i have a table with two columns cust and price, i want to write a rule ,
>the value of price must be >= cust * 1,4 , the ideia is not permit write in
>price a value minor of 40 % profit, how i can write this?
> Thanks in advance
> Alejandro Carnero
>|||Well, I am just going to guess about the exact implementation but something
like:
alter table tableName add constraint tableName$checkPriceAndCust check
(price >= (cust * 1.4))
if this doesnt work, post the table create statement and some sample data
and it will be easier to make sure that it does
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"alejandro" <alecarnero@.uol.com.br> wrote in message
news:e1GydsEHGHA.2300@.TK2MSFTNGP15.phx.gbl...
>i have a table with two columns cust and price, i want to write a rule ,
>the value of price must be >= cust * 1,4 , the ideia is not permit write in
>price a value minor of 40 % profit, how i can write this?
> Thanks in advance
> Alejandro Carnero
>|||where i write this check constraint? in the enterprise manager?
"JT" <someone@.microsoft.com> escreveu na mensagem
news:%23hJYL0EHGHA.3944@.tk2msftngp13.phx.gbl...
> This can be implemented using a table level 'check constraint'.
> "alejandro" <alecarnero@.uol.com.br> wrote in message
> news:e1GydsEHGHA.2300@.TK2MSFTNGP15.phx.gbl...
in
>|||Yes, in EM, open the design dialog for a table, click on the properties
icon, then click on the Check Constraints tab. Also, this can be done using
T-SQL script, and Louis provides an example.
"alecarnero" <alecarnero@.uol.com.br> wrote in message
news:%233LQnmTHGHA.312@.TK2MSFTNGP09.phx.gbl...
> where i write this check constraint? in the enterprise manager?
>
> "JT" <someone@.microsoft.com> escreveu na mensagem
> news:%23hJYL0EHGHA.3944@.tk2msftngp13.phx.gbl...
> in
>

No comments:

Post a Comment