473,626 Members | 3,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do ALTER TABLE after a DML sentece in the same transaction.

NKN
Hi all,

Does anybody know how could I manage to do a sentence like this...

ALTER TABLE Table1 DROP COLUMN Col1

after doing a DML sentence like and UPDATE, INSERT or DELETE.

I'm using ADO commands to execute all thiis sentene from VB.

The problem is that if all this is in the same transaction when I try
droping the column in the same table that I've updated before I get an
error. The object is locked and I can't drop the column.

Thanks in advance for your suggestions,

Naiara.
Nov 13 '05 #1
1 1866
NKN wrote:
Hi all,

Does anybody know how could I manage to do a sentence like this...

ALTER TABLE Table1 DROP COLUMN Col1

after doing a DML sentence like and UPDATE, INSERT or DELETE.

I'm using ADO commands to execute all thiis sentene from VB.

The problem is that if all this is in the same transaction when I try
droping the column in the same table that I've updated before I get an
error. The object is locked and I can't drop the column.

Thanks in advance for your suggestions,

Naiara.


The need to drop a column from a table would suggest it's not in the
right format to begin with, perhaps you just imported it? Try importing
into an exiting table using an import spec that ignores the extra column
from the external source.

Otherwise if you've used that column for some temporary calculations and
no longer need it, just leave it where it is and ignore it, e.g., use a
query that selects all but that column.

--
This sig left intentionally blank
Nov 13 '05 #2

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

Similar topics

4
7397
by: dayong | last post by:
i need to alter all foreign keys in my database and uncheck the "Enforce relationship for replication" check box. Using the EM, I extracted the code snippet below. unfortunately, when i run this test from query analyzer, then go back into the EM, the box is still checked. can anyone tell me what i am missing? any advice on unsetting this attribute globally would be appreciated! BEGIN TRANSACTION
2
1872
by: Gordowey | last post by:
I have the next question, and i would like to hear what do you think about, and if is there a better solution for "my problem" here is the question, I have a huge table with 60GB of data (image files). The problem happen always when i try to ALTER the structure of the table. For example I change a field char(3) to char(4)...the sqlserver then performs the "alter table" command...that must be something similar than "insert into the new...
4
15371
by: xixi | last post by:
hi, i have a table with create ddl using not logged initially, CREATE TABLE "NJIPD "."IVPWGMR" ("IVDY01" DECIMAL(2,0) , "IVMO01" DECIMAL(2,0) , "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY ( START WITH +1 , INCREMENT BY +1 , NO CACHE ) ) IN "USERSPACE1" NOT LOGGED INITIALLY ; right now i have to delete almost one million rows in the table, so i found that i can use alter table activate not logged initially before i...
4
3905
by: Jeff Kish | last post by:
Hi. I have a database I need to supply something (I'm assuming a t-sql script.. maybe something else is better) to update customer tables with. The operations include mostly changing varchar lengths, though a couple of columns were renamed. I'd like to maybe figure out how to get Enterprise Manager or Query Analyzer to generate the scripts.
4
23809
by: Brian Wotherspoon | last post by:
Hi all, I'm using SQL Server 2000 SP3 to store data for real time transaction processing. I have set up replication to another server using a push subscription to give me immediate backup. I need to alter the data type of one of the columns and am using the following basic sql:
7
6975
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who need to do produce change scripts to upgrade application from release to release, but it can also
0
3645
temat
by: temat | last post by:
Hi i got a problem when i try to Alter Table in the procedure. I have red that i need to place keyword IMMIDIATE but it dont work in mssql. I need thede procedure to drop FOREIGN KEY, TRUNCATE and add FOREIGN KEY -- PUBLISHERS ALTER PROCEDURE clearPublishers AS BEGIN TRANSACTION ALTER TABLE dbo.Books DROP CONSTRAINT FK_Publishers_Books
4
3677
by: cuneyt.barutcu | last post by:
The following ALTER takes about 2 hours in my environment. total number of records is about 2.8 million. IS this typical? Is there a way to speed up this process. BEGIN TRANSACTION SET QUOTED_IDENTIFIER ON SET TRANSACTION ISOLATION LEVEL SERIALIZABLE SET ARITHABORT ON SET NUMERIC_ROUNDABORT OFF SET CONCAT_NULL_YIELDS_NULL ON SET ANSI_NULLS ON
2
11958
by: NarutoFanatic | last post by:
Hello, I'm having trouble using a transaction - rollback statement in sql. I can't seem to have the rollback executed during an error when i've altered a table to add a column with the same name (run the alter script twice on purpose to test the rollback). Somehow i got an error of the column should be unique (since the column already added during the 1st execution of the script). I want the sql execution to display the Failed instead and...
0
8199
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.