--Requirements change, need to add a foreigner name to the F_username field of the T_login table, the previous set of varchar (10) is not enough, the negotiation decision to change to varchar (30), when executing, the message index ' Uq_f_username ' depends on the column ' F_ UserName '. ALTER TABLE ALTER COLUMN F_USERNAME failed because one or more objects access this column.
--Originally, a unique index uq_f_username was added to prevent f_username duplication.
--After doing the following, the problem is duly resolved.
--Table name: T_login (Login table)
--Field: f_username (user name)
--Execution requirements: Change the f_username length from varchar (10) to varchar (30)
--Syntax format
--Delete the previous index
Drop Index uq_f_username on T_login
Go
--Modify field length
ALTER TABLE t_login ALTER COLUMN f_username varchar (30)
Go
--Re-create INDEX
Create unique nonclustered index [uq_f_username] on [dbo]. [T_login]
(
[F_username] ASC
)
--created when the index does not exist
where ([f_username] is not null)
--This is a series of SQL Server indexes, self-brain: https://msdn.microsoft.com/zh-cn/library/ms188388.aspx
With (Pad_index = off, Statistics_norecompute = off, sort_in_tempdb = off, Ignore_dup_key = off, drop_existing = off, Onli ne = off, allow_row_locks = on, allow_page_locks = ON)
Go
--After the previous index fails, modify the index to prevent the index modification from failing
Alter INDEX [UQ_F_USERNAME] on [dbo]. [T_login] Disable
Go
MSSQL Server index ' Uq_f_username ' relies on column ' F_username '. ALTER TABLE ALTER COLUMN F_USERNAME failed because one or more objects access this column