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
 General SQL Server Forums
 New to SQL Server Programming
 Adding a column and updating the column

Author  Topic 

123apple
Starting Member

2 Posts

Posted - 2008-07-13 : 22:42:23
I would like to add a new column to a table that takes the information from another column and subtracts 10% from that number. The following is what I have so far. I don't know how to complete the trigger statement to set the information from the other row. Additionally, I want to make the default value of the new column pListPrice -10%. Any ideas would be much appreciated! Thanks!

ALTER TABLE products ADD a_price DOUBLE DEFAULT (SELECT pListPrice FROM products ;

CREATE TRIGGER t_products BEFORE UPDATE ON products FOR EACH ROW SET

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-13 : 22:50:42
are you using Microsoft SQL Server ?

SQL Server does not support BEFORE UPDATE


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-07-13 : 22:55:38
It's not for sql server, since there is no double data type in sql server.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-13 : 22:58:43
We use double data type in sybase.
Go to Top of Page

123apple
Starting Member

2 Posts

Posted - 2008-07-13 : 23:55:16
I'm sorry: I'm not sure what server I use, but I can use a double data type so it must not be a Windows server.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-13 : 23:59:57
You will need to find out what database server are you using and post in the appropriate forum. FYI this is a Microsoft SQL Server forum. Try dbforums.com


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -