1
I need to modify the column type of a client table, however this change will be made through a program written in VB.Net and therefore needs to be done via SQL command.
The point is that when using the command:
ALTER TABLE Customer ALTER COLUMN COLUNA int;
I receive the following message:
The object 'DF__Tmp_Customer__Coluna__15BB0E23' is dependent on column 'Coluna'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN Coluna failed because one or more objects access this column.
I cannot in any way apply any amendment to the column in question...
Is this SQL Server? It seems to me that you have a reference to this column somewhere, try to find where it is.
– Maniero
Exactly, using sql server 2008 R2
– Cleiton Ribeiro
May have been created some Constraint automatically by DB. Can be in stored Procedure, in Function. Have you tried with
NOCHECK CONSTRAINT
? Remember to experiment on data that can be corrupted if you do something wrong. you may have to make aDROP CONSTRAINT
.– Maniero
Funny, that when I try to remove the Constraint 'Df__tmp_customer_coluna__15bb0e23' sql tells me that this object does not exist... but when I try to change the column, sql tells me that this Constraint is dependent on the field.
– Cleiton Ribeiro
Probably because DB created it. It might even have been created because of default value. Have you tried going through all the objects in the database looking for it? Can you do darlings in the DB system tables (not in their tables)?
– Maniero
Guys, I managed to solve... I managed a Constraint drop script by the bank and removed it quietly.
– Cleiton Ribeiro
@Kleitonribeiro add the script as a response or try to give some lights as resolved so that future generations also know how to solve.
– Omni
@Omni ready :D entered the answer !
– Cleiton Ribeiro
@Please insert your solution as an answer, not as an edit to your question.
– gmsantos
@Omni All right, thank you very much!
– Cleiton Ribeiro