473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How can I insert a column using a script (instead of appending)?

Hi,

I recently had to add a new column to a table that resides off-site,
in a customer's environment. Previously, the table had around 300
columns, all of which were in alphabetical order.

I found that the ALTER TABLE command appeared to be only capable of
appending a new column, but wasn't capable of inserting one into the
middle of the table.

Since alphabetical order wasn't a requirement, but just a "nice to
look at" feature, I appended it anyway, and forgot about it.

Anyone know of a clever way to do this though?

Curiously,

Warren Wright
Scorex Development Team
Jul 20 '05 #1
1 3266
Warren Wright (wa***********@us.scorex.com) writes:
I recently had to add a new column to a table that resides off-site,
in a customer's environment. Previously, the table had around 300
columns, all of which were in alphabetical order.

I found that the ALTER TABLE command appeared to be only capable of
appending a new column, but wasn't capable of inserting one into the
middle of the table.

Since alphabetical order wasn't a requirement, but just a "nice to
look at" feature, I appended it anyway, and forgot about it.

Anyone know of a clever way to do this though?


The "clever" way is to fiddle with syscolumns, but I highly discourge
from this.

The normal way is to go the long way: rename the old table, create
the new table including triggers, constrains and clustered index, insert
data from the old table to the new, move referencing foreign keys, drop the
old table. Restore non-clustered index.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason | last post by:
The best way to explain this is by example. I have a source table with many columns. Source SYMBOL EXCHANGE_NAME CUSIP TYPE ISSUE_NAME
1
by: Cliff | last post by:
I'm trying to do multiple insert statements. The table looks like this: CREATE TABLE $table (CNTY_CNTRY_CD char(3),ST char(2), CNTY_CNTRY_DESCR varchar(50),CNTY_CNTRY_IND char(1),...
2
by: JP SIngh | last post by:
I am having problems inserting data into a simple table Insert into Forums (Title, PageUrl, ContractId) Values ('54249', 'test01.asp',54249) Microsoft OLE DB Provider for SQL Server error...
3
by: rdraider | last post by:
I'm doing a data conversion project, moving data from one SQL app to another. I'm using INSERT INTO with Select and have the syntax correct. But when executing the script I get: Server: Msg...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
4
by: JMCN | last post by:
is it possible to insert a value into a field when you append the new records to the table instead of appending the one new record at a time in order to insert a new value? for example, i would...
3
by: A Lonely Programmer | last post by:
Ok i know that using an access db is a corporate nono but i am not about to buy sql for anybody (well maybe myself someday) and an approved msde update must come AFTER i get certain things up and...
3
by: teddysnips | last post by:
I need a trigger (well, I don't *need* one, but it would be optimal!) but I can't get it to work because it references ntext fields. Is there any alternative? I could write it in laborious code...
1
by: trint | last post by:
Hello professionals, I have a datagridview that displays columns based upon my sql select statement. I have additional columns that I want displayed in the datagridview I wish to append to the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.