Delete a field/column from a table???

Delete a field/column from a table???

Post by Derek Er » Tue, 24 Nov 1998 04:00:00



I have been through the Server books online, Inside SQL Server 6.5, SQL
Server 6.5 Programming Unleashed.

Nowhere can I find any instructions on how to delete (drop) a field/column
from a table.  I can't possibly be the first person needing to do this.

There must be some easy command to do this...

Can someone please point me in the right direction?

Thank you in advance.

-----
Please reply via EMail *AND* Newsgroup if possible.


Paris, FRANCE                      Web: http://www.erb.com

 
 
 

Delete a field/column from a table???

Post by Ron Talmag » Tue, 24 Nov 1998 04:00:00


Derek,

I SQL Server 6.5 there is no direct way to delete a column or change a
column's data type. However, you can use Visual Studio's visual data tools
to do it behind the scenes, or write a script yourself to do it manually.

Ron

 
 
 

Delete a field/column from a table???

Post by Greg Druia » Tue, 24 Nov 1998 04:00:00


You need to rename the existing table, create a new table having only the
columns you want, and finally INSERT records from the old table into the new
table--including only the fields you want to keep in the INSERT statement.  I
understand that in SQL Server 7.0 there will be a less cumbersome way to do
this.

> I have been through the Server books online, Inside SQL Server 6.5, SQL
> Server 6.5 Programming Unleashed.

> Nowhere can I find any instructions on how to delete (drop) a field/column
> from a table.  I can't possibly be the first person needing to do this.

> There must be some easy command to do this...

> Can someone please point me in the right direction?

> Thank you in advance.

> -----
> Please reply via EMail *AND* Newsgroup if possible.


> Paris, FRANCE                      Web: http://www.erb.com

 
 
 

Delete a field/column from a table???

Post by Derek Er » Fri, 27 Nov 1998 04:00:00


Ron Talmage a crit dans le message ...

Quote:>I SQL Server 6.5 there is no direct way to delete a column or change a
>column's data type. However, you can use Visual Studio's visual data tools
>to do it behind the scenes, or write a script yourself to do it manually.

I don't use Visual Studio.  However I'm pretty good with scripts... can you
give me an idea as to how I could do this with a script (ISQL, VB,
whatever)?

In the other message someone mentioned copying the table's contents using an
elaborate INSERT statement.  However this doesn't take in to consideration
the triggers, DRI, indexes, etc....

I certainly hope this sort of incredibly basic task (ie deleting a
field/column in a table) is possible with SQL 7!!!

Thanx.

-----
Please reply via EMail *AND* Newsgroup if possible.


Paris, FRANCE                      Web: http://www.erb.com

 
 
 

1. Dropping column silently kills multi-coumn index (was [ODBC] Error when accessing tables with deleted columns)

I see the connection you're trying to make there, but I don't think it
quite follows.  When you drop a table, all its indexes logically become
orphaned and so can be quietly dropped; who would expect the indexes to
stay?  When you drop a column that belongs to a multi-column index on
the other hand, the index does not become logically orphaned.  It
becomes... Something else...  I think it could be an intuative
expectation that the server should re-structure the index minus the
dropped field.  In other words, the index *can* exist without the
dropped field, just not in its current form.  Because of that
uncertainty, it makes sense to me to refuse to drop the column.  The
reason I suggested the same behavior for *single* column indexes is
purely for constistancy.

The post that got me looking into this showed that exact uncertainty;
there was a question whether the index was dropped or not.

And no, requiring CASCADE on table drops to get rid of indexes makes
exactly zero sence to me :-)

Glen

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate

message can get through to the mailing list cleanly

2. TEXT fields giving me the runaround

3. New Network Card Now Can't Connect in EM by Name

4. instead of delete trigger delete data from table using execute and temporary table for deleted

5. pgsql-server/src backend/commands/Tag: backend ...

6. W4GL : Option Fields as columns in Table Fields

7. Introducing myself

8. deleting specific columns from a field

9. Need some help deleting specific columns from a field

10. Delete Column at Database Table

11. Deleting a column from a table

12. Using Enterprise Manager to delete a column in table (SQL 6.5)