开发者

Alter column drops index

开发者 https://www.devze.com 2022-12-09 17:09 出处:网络
I have a table CREATE TABLE table1( [classe] [char](30) NOT NULL, [code] [char](30) NOT NULL,开发者_运维知识库

I have a table

CREATE TABLE table1(
 [classe] [char](30) NOT NULL,
 [code] [char](30) NOT NULL,开发者_运维知识库
 [description] [varchar](255) NULL,
 [codelangue] [char](2) NULL
) ON [PRIMARY]

with the index

CREATE NONCLUSTERED INDEX [table1_id1] ON [dbo].[table1] 
(
 [codelangue] ASC,
 [classe] ASC,
 [code] ASC
)
INCLUDE ( [description]) WITH (PAD_INDEX  = OFF, 
STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, 
IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

When I do

ALTER TABLE table1
ALTER COLUMN codelangue [char](2) NOT NULL

it drops the index and the associated statistique.

Any idea why?


ALTER TABLE table

I assume this should be "table1" instead of "table"?

On my installation of SQL Server 2005, this code generates an error:

Msg 5074, Level 16, State 1, Line 1
The index 'table1_id1' is dependent on column 'codelangue'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN codelangue failed because one or 
more objects access this column.


Different table (eg bob.table1 not dbo.table1) or different database.

The ALTER will not execute on any version of SQL Server I'm familiar with

0

精彩评论

暂无评论...
验证码 换一张
取 消