add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE DoingStuff (
DoingStuffID int NOT NULL IDENTITY(1,1),
TaskText varchar(20)
);
CREATE STATISTICS BreakingStuff ON DoingStuff (TaskText) WITH FULLSCAN;
INSERT INTO DoingStuff (TaskText)
VALUES
('Who Cares'),
('Not today'),
('Not sure');

3 rows affected
SELECT DoingStuffID, TaskText FROM DoingStuff;
DoingStuffID TaskText
1 Who Cares
2 Not today
3 Not sure
PRINT 'Modify the table''s column TaskText to allow varchar(50)'
Modify the table's column TaskText to allow varchar(50)

ALTER TABLE DoingStuff
ALTER COLUMN TaskText varchar(50);
SELECT DoingStuffID, TaskText FROM DoingStuff;
DoingStuffID TaskText
1 Who Cares
2 Not today
3 Not sure
PRINT 'Modify the table''s column TaskText to varchar(40)'
Modify the table's column TaskText to varchar(40)

ALTER TABLE DoingStuff
ALTER COLUMN TaskText varchar(40);
Msg 5074 Level 16 State 1 Line 1
The statistics 'BreakingStuff' is dependent on column 'TaskText'.
Msg 4922 Level 16 State 9 Line 1
ALTER TABLE ALTER COLUMN TaskText failed because one or more objects access this column.
SELECT DoingStuffID, TaskText FROM DoingStuff;
DoingStuffID TaskText
1 Who Cares
2 Not today
3 Not sure
PRINT 'Drop Statistics and then modify the table''s column TaskText to varchar(40)'
Drop Statistics and then modify the table's column TaskText to varchar(40)

DROP STATISTICS DoingStuff.BreakingStuff;
ALTER TABLE DoingStuff
ALTER COLUMN TaskText varchar(40);
SELECT DoingStuffID, TaskText FROM DoingStuff;
DoingStuffID TaskText
1 Who Cares
2 Not today
3 Not sure