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
 add a field + trim

Author  Topic 

carissa
Starting Member

3 Posts

Posted - 2009-03-26 : 15:25:21
this is a beginner question, how do I add a new field to my table? the datatype is double

also, i need to remove a negative sign that precedes the number from a group of records. ltrim rtrim works for spaces, but what about characters?

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-03-26 : 15:35:56
use ALTER TABLE and ADD COLUMN to add a new column.

whats the data type of the field with the negatives
Go to Top of Page

carissa
Starting Member

3 Posts

Posted - 2009-03-26 : 15:39:45
it is double
Go to Top of Page

carissa
Starting Member

3 Posts

Posted - 2009-03-26 : 15:46:21
to add a column would i do this?

alter table (name of table)
add column

how do i name it? do i need to specify the datatype?
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-26 : 16:24:15
Yes. You'd need to specify datatype. You can give anyname to it. Try avoiding sql keywords.
e.g.
ALTER TABLE yourtable ADD newcolumn VARCHAR(100) NULL


There are many arguments to ALTER TABLE.Look in BOL if you have doubts. Its explained very well there.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-26 : 16:27:59
As for removing -ve sign, You can use ABS function. It'll return you the positive value of the expression.
Go to Top of Page
   

- Advertisement -