Latest Post

Thursday, 27 July 2017

How We Can ALTER COLUMN ONLINE in Sql Server 2016

ALTER COLUMN ONLINE

We can ALTER TABLE now or alter many columns while the table remains online, using WITH (ONLINE = ON | OFF).


DROP TABLE IF EXISTS dbo.[dbo].[Base_Users]
CREATE TABLE [dbo].[Base_Users](
       [Id] [int] IDENTITY(1,1) NOT NULL,
       [Name] [nvarchar](50) NULL,
       [Address] [nvarchar](max) NULL,
       [ContactNumber]  AS (json_value([address],'$.Contact_Number')),
PRIMARY KEY CLUSTERED
(
       [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE dbo.Base_Users
    ALTER COLUMN ContactNumber VARCHAR(255) NOT NULL
    WITH (ONLINE = ON)
GO

ALTER TABLE dbo.Base_Users
ALTER COLUMN ContactNumber NVARCHAR(255)

    COLLATE Cyrillic_General_100_CI_AS NOT NULL

Government Jobs