views:

253

answers:

2

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?

A: 
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.
Andomar
If a recreate the index and pas the column in NULL and then I retry to pass it in NOT NULL I get the same error...but not the first time and I don't understand why....
Roxana
yup, same here - I can't execute that statement to alter the table's column
marc_s
A: 

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

gbn