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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Add New fieilds .

Author  Topic 

admin001
Posting Yak Master

166 Posts

Posted - 2002-11-14 : 04:07:41
Hello ,

I wish to add new columns on some tables in one database like :

Existing Table Name : Inventory
New Column name to be added : Product
Data Type of the new column : Text
Field Size : 8

My server is SQL 7.0 with SP 4 . From the BOL i found out to alter the existing columns with different field length , but i did not get anything on adding new fields .
Can we do this thorugh the SQL EM ??

Any help ?

Thanks



nr
SQLTeam MVY

12543 Posts

Posted - 2002-11-14 : 04:12:20
always worth playing with temp tables to test things

create table #a (i int)
alter table #a add j int
select * from #a

(I never like doing this)

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

admin001
Posting Yak Master

166 Posts

Posted - 2002-11-14 : 04:32:19
Thanks once again NR . Would you explain the steps so that it will be more clear .

Create table #a ( i int ) -- What is ( i int ) ?
Alter table #a add j int --- Where do we specify the new column name ?

Select * from #a --I guess this is the final step to copy the changed data into the existing table .

Sorry, i have not done this before so would like your assistance .

Can i have further help in this regard ?

Thanks

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-11-14 : 05:01:49
nope - I am just giving an example with a temp table.
the command is
Alter table <tblname> add <column definition>

so

alter table mytbl add newcol1 int
alter table mytbl add newcol2 varchar(20)
alter table mytbl add newcol3 datetime not null default getdate()

will add 3 cols newcol1, newcol2, newcol3 to mytbl





==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -