You are here: Re: Deleting a column DEFAULT.... « MsSQL Server « IT news, forums, messages
Re: Deleting a column DEFAULT....

Posted by sonu on 07/26/06 09:41

Actually I m also facing the same problem. I had need of fetching data
from two tables for which we used Diagram for inner joining. Later I
found that in VB.Net when we update or save any new data in one of
those tables which were inner joined it was showing error, so we
deleted that diagram and updated the data without joining.
Now when we try to delete some data from one of those tables it shows
message Delete statement conflicted with COLUMN REFERENCE constraint
<constraint name >The conflict occured in database <databasename>,table
tablename,column <columnname>

Kindly give solution of this problem.
sonika.


Gert-Jan Strik wrote:
> Giacomo,
>
> You must use ALTER TABLE ... DROP CONSTRAINT to drop the column default.
>
> Another option (than the one posted by Erland) is to recreate the
> column. Note that this will only work if there is no DRI on the column,
> and no indexes. For example:
>
> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
> BEGIN TRANSACTION
>
> EXEC sp_rename 'PlanningDettaglio.OreStraordinario', '__old', 'COLUMN'
>
> ALTER TABLE PlanningDettaglio
> ADD OreStraordinario DECIMAL(18,2) NULL -- or whatever the original
> definition
>
> UPDATE PlanningDettaglio
> SET OreStraordinario = __old
>
> ALTER TABLE PlanningDettaglio DROP COLUMN __old
>
> COMMIT TRANSACTION
>
> HTH,
> Gert-Jan
>
>
> Giacomo wrote:
> >
> > Hi,
> > I've the following problem. I must delete a column DEFAULT from a table,
> > but I must do it with a script, independently from the server where it'll
> > be executed.
> > Locally I've tried with:
> >
> > ALTER TABLE [dbo].[PlanningDettaglio]
> > DROP CONSTRAINT [DF__PlanningD__OreSt__688C6DAC]
> > GO
> >
> > ALTER TABLE [dbo].[PlanningDettaglio]
> > ALTER COLUMN [OreStraordinario] varchar(5)
> > GO
> >
> > ALTER TABLE [dbo].[PlanningDettaglio]
> > ADD DEFAULT ('00.00') FOR [OreStraordinario]
> > GO
> >
> > it works, but only locally.
> > I've tried with:
> >
> > ALTER TABLE PlanningDettaglio ALTER COLUMN OreStraordinario DROP DEFAULT
> >
> > Err.: Incorrect syntax near the keyword 'DEFAULT'.
> >
> > Can someone help me please?
> >
> > Thanks in advance,
> > Giacomo
> >
> > P.S.
> > We're using SQL Sever 2000 (version 8.00.194)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация