SQL Server Articles, Tips, FAQs, Reviews, Whitepaper, News etc - MyTechMantra.com

ALTER TABLE WITH (ONLINE=ON | OFF) T-SQL Enhancement in SQL Server 2016

Previous Page.. Begin Tutorial.. Next Page..

SQL Server 2016 introduces an interesting T-SQL enhancement to improve performance and reduce downtime ALTER TABLE WITH (ONLINE = ON | OFF). This statement will help you alter data types, change column/table collation values, change nullability settings, change column length, and many other options while the table remains online for user connectivity.

This is Part 4 of 10 Part T-SQL Enhancements in SQL Server 2016 for Developers and DBAs. Click here to read it from the beginning….

However, this feature is turned off by default in SQL Server 2016. In case, if you wish to utilise this feature then you would need to specify ALTER TABLE WITH (ONLINE = ON) option.

Trending SQL Server Articles and Tips

Example ALTER TABLE WITH (ONLINE = ON | OFF)

DROP TABLE IF EXISTS ProductPrice
GO
CREATE TABLE ProductPrice (Price INT)
GO

INSERT INTO ProductPrice (Price) VALUES (1250);
INSERT INTO ProductPrice (Price) VALUES (1252);
INSERT INTO ProductPrice (Price) VALUES (1254);
INSERT INTO ProductPrice (Price) VALUES (1256);
INSERT INTO ProductPrice (Price) VALUES (1258);

ALTER TABLE ProductPrice
ALTER COLUMN Price DECIMAL (5, 2) WITH (ONLINE = ON)
GO

SELECT Price FROM ProductPrice
GO	

Clicking Next Page button to continue reading the topics and click on the Previous Page button to revisit the previous topic.

Previous Page.. Begin Tutorial.. Next Page..

Related Topics

Ashish Mehta

Ashish Mehta

Ashish Kumar Mehta is a database manager, trainer and technical author. He has more than a decade of IT experience in database administration, performance tuning, database development and technical training on Microsoft SQL Server from SQL Server 2000 to SQL Server 2014. Ashish has authored more than 325 technical articles on SQL Server across leading SQL Server technology portals. Over the last few years, he has also developed and delivered many successful projects in database infrastructure; data warehouse and business intelligence; database migration; and upgrade projects for companies such as Hewlett-Packard, Microsoft, Cognizant and Centrica PLC, UK. He holds an engineering degree in computer science and industry standard certifications from Microsoft including MCITP Database Administrator 2005/2008, MCDBA SQL Server 2000 and MCTS .NET Framework 2.0 Web Applications.

Add comment

Newsletter Signup! Join 15,500+ Professionals




Be Social! Like & Follow Us...

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Recent SQL Server Tips