Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i have one table

id    name  marks
1     aaa    50
2     bbb    60

and marks datatype is int default 0

and now i have change datatype float
SQL
ALTER TABLE AAA
ALTER COLUMN marks float


now i get error

ALTER TABLE ALTER COLUMN marks failed because one or more objects access this column.

give me idea how to change datatype
thanks to advance
Posted

 
Share this answer
 
Comments
[no name] 9-Aug-13 6:49am    
if possible please give me example in my table thanks
For that you need to remove realted Table Constrain First. Like

ALTER TABLE table2
DROP CONSTRAINT FK_table2_table1;
ALTER TABLE table1
DROP CONSTRAINT PK_table1;

ALTER TABLE table1
ALTER COLUMN column1 nvarchar(32) NOT NULL;
ALTER TABLE table2
ALTER COLUMN column1 nvarchar(32);

ALTER TABLE table1
ADD CONSTRAINT PK_table1
PRIMARY KEY (column1, column2)

ALTER TABLE table2
ADD CONSTRAINT FK_table1_table2
FOREIGN KEY (column1, column2)
REFERENCES table1(column1, column2)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900