|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 3:16 PM
Points: 2,749,
Visits: 1,405
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Sunday, December 04, 2011 10:06 AM
Points: 2,
Visits: 9
|
|
Other activity on my PC meant that I was a victim of cursor lag (the blinking cursor, not the SQL one). As a result, when I clicked on what I thought was 5 stars, I actually gave 1 star. Sorry.
Excellent article, with the part about Cinderella users ringing so true. "Rats nest of Excel spreadsheets" indeed!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 8:00 AM
Points: 1,065,
Visits: 698
|
|
sporran (5/25/2010) As a result, when I clicked on what I thought was 5 stars, I actually gave 1 star.
Added one star extra. If 3 other persons will do that...
Good article.
Dutch Anti-RBAR League
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 9:24 AM
Points: 70,
Visits: 193
|
|
I clicked on 5 stars...something out there decided that should be 4!
I'll be sharing this with a few of my colleagues - I really hope they take the not-so-subtle hint!!
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, March 23, 2012 3:28 AM
Points: 1,
Visits: 26
|
|
| Great article - thank you for writing it!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 8:59 AM
Points: 1,026,
Visits: 750
|
|
Excellent article, thanks for sharing. I look forward to the next installment!
If such a facility existed I would suggest it be pinned, and enshrined in the hall of fame.
However, if you were to write and publish a version of this aimed at SQL Developers it would make a lot of DBA's lives a lot easier. As it stands forwarding this to the Devs as a standalone might bite back... ;)
Cheers
Rich
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, April 18, 2011 6:39 AM
Points: 1,
Visits: 69
|
|
Your "Cinderella Data Users" sub heading made me laugh.. I work for a huge organization and work in such a department and only hope someone higher up the food chain here reads your article and takes note.
M$ Office/SQL Express are the only tools available to me, I have projects with deadlines that need meeting just like the heavy hitting DBAs in the organization - I'm sure that this will lead to problems for them should I ever leave but seriously, the support isn't there for me now so I must do what I must.
Excellent article, Thanks!
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 10:33 AM
Points: 10,989,
Visits: 10,529
|
|
David,
I just scanned through on a first read, but something important caught my eye:
In the section on changing data types (after rebuilding the clustered index) you say that for SQL Server 2005: "Fixed length datatype sizes are imutable. Changes are only at the metadata level."
This is not so.
Rebuilding the clustered index does indeed reclaim the space. There is a simplified script at the end of this post to demonstrate. I have also tried your script (with my own ALTER TABLE ALTER COLUMN statements) and received the same results.
These are the statements I used with your script:
ALTER TABLE dbo.FinancialStatsLarge ALTER COLUMN AnnualInterestRate DECIMAL(5,2) NOT NULL; ALTER TABLE dbo.FinancialStatsLarge ALTER COLUMN MonthlyInterestRate DECIMAL(5,2) NOT NULL; ALTER TABLE dbo.FinancialStatsLarge ALTER COLUMN AnnualFee DECIMAL(9,2) NOT NULL; ALTER TABLE dbo.FinancialStatsLarge ALTER COLUMN MonthlyFee DECIMAL(9,2) NOT NULL; ALTER TABLE dbo.FinancialStatsLarge ALTER COLUMN AnnualCost DECIMAL(9,2) NOT NULL; ALTER TABLE dbo.FinancialStatsLarge ALTER COLUMN MonthlyCost DECIMAL(9,2) NOT NULL; GO ALTER INDEX [PK_FinancialStatsLarge] ON dbo.FinancialStatsLarge REBUILD; Demo:
CREATE TABLE dbo.Immutable ( row_id INTEGER NOT NULL IDENTITY (1,1) CONSTRAINT [PK dbo.Immutable row_id] PRIMARY KEY, data DECIMAL(18,2) NOT NULL);
INSERT dbo.Immutable (data) VALUES (1.23);
-- Show table page data DBCC IND (0, Immutable, 1);
-- Redirect DBCC PAGE output from the error log to the client window DBCC TRACEON(3604);
-- Page 14830 in file 1 was the data page on my test run DBCC PAGE (0, 1, 15162, 3);
--==================================== -- DBCC PAGE EXTRACT --==================================== -- -- Slot 0 Offset 0x60 Length 20 -- -- Slot 0 Column 0 Offset 0x4 Length 4 row_id = 1 -- Slot 0 Column 1 Offset 0x8 Length 9 data = 1.23 -- --====================================
-- Alter the column definition -- Metadata-only change at this stage ALTER TABLE dbo.Immutable ALTER COLUMN data DECIMAL(5,2) NOT NULL;
-- Rebuild the clustered index ALTER INDEX [PK dbo.Immutable row_id] ON dbo.Immutable REBUILD;
-- The data page allocated will have changed DBCC IND (0, Immutable, 1);
-- Data now on page 15163 in file 1 on my test run DBCC PAGE (0, 1, 15163, 3);
--==================================== -- DBCC PAGE EXTRACT --==================================== -- -- Slot 0 Offset 0x60 Length 16 -- -- Slot 0 Column 0 Offset 0x4 Length 4 row_id = 1 -- Slot 0 Column 1 Offset 0x8 Length 5 data = 1.23 -- -- Notice the record as a whole is 4 bytes shorter -- and column 1 is *physically* 5 bytes now -- --====================================
DROP TABLE dbo.Immutable; DBCC TRACEOFF (3604);
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 16, 2011 7:09 AM
Points: 5,
Visits: 34
|
|
"Cinderella data users"
Very aptly stated. This is where I live. Every day. Nice article.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Sunday, March 04, 2012 9:49 AM
Points: 10,
Visits: 49
|
|
| Nicely, nicely done. Six stars.
|
|
|
|