0

I have a table student containing a date column dateModified which is not nullable. I want to change the column data type to datetime. I tried following sql in the MSSql server:

ALTER table student alter column dateModified datetime not null

and getting following error:

The object '....' is dependent on column 'dateModified'
ALTER TABLE STUDENT ALTER COLUMN DATEMODIFIED DATETIME NOT NULL failed because one or more objects access this column.

There is no constraints depending on the column. there is a primary key which is not related to the column.

There are thousands of existing records in the student. I tried running the sql in a empty table and it worked without any errors. Could anyone please tell me how can I alter the table without removing any records from the table? If possible please also provide a sql for Oracle sql. Thanks in advance.

Md. Farzad
  • 21
  • 3
  • No, Because there is no constraints on the column. – Md. Farzad Feb 12 '20 at 12:16
  • *Something* is using that column. It may be a foreign key, a constraint or a default. In fact, the error seems to be telling you what is going on already - `The object 'XZYZ' is dependent on column 'dateModified'`. What object is this? – Panagiotis Kanavos Feb 12 '20 at 12:19
  • The error message gives you a specific name - what is that name and what type of object is it? – SMor Feb 12 '20 at 12:44

0 Answers0