March 2, 2014 at 10:53 pm
Hello all,
I have to change the datatype of a column in all tables of a database where that column exists.
For this I disable the constraint of all the tables runing this query:
EXEC sp_msforeachtable 'Alter table ? NOCHECK Constraint ALL'
After this when I run the query to change datatype of column I am getting error like:
ALTER TABLE ALTER COLUMN column1failed because one or more objects access this column.
The object 'uq1_Building' is dependent on column 'column1'.
What should I do to accomplish this?
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
March 3, 2014 at 12:10 am
Check for FK relationships, I believe you have to drop the FK constraints first, then try what you were doing.
Try running sp_help on the tables to see what is tied to it...this will let you know if FK's, user created statistics, or schema-binded views reference the column.
Also, make sure no indexes exist using that column, while I'm not 100% sure on this, it could also be causing your issue.
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
March 3, 2014 at 1:22 am
yes I have unique contraint , nonclusted index exists on tables might be they are causing this issue....
But I dont have any idea that can we disable uniquest constraint or not....
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
March 3, 2014 at 4:49 am
You need to drop all constraints, check constraints, foreign key, unique constraints, not disable them.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 3, 2014 at 5:32 am
Just wanted to share that I burped a while ago 😀
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply