
BEGIN TRANSACTION
BEGIN TRY
SELECT *
INTO sExamination.tOPDFitnessStatus_Temp
FROM sExamination.tOPDFitnessStatus
WHERE 1 = 0;

ALTER TABLE sExamination.tOPDFitnessStatus_Temp
DROP COLUMN Id;

ALTER TABLE sExamination.tOPDFitnessStatus_Temp
ADD Id INT; -- no identity

INSERT INTO sExamination.tOPDFitnessStatus_Temp
(
    Id,
    FitnessStatusId,
    OrgId,
    IsObsolete,
    Code,
    Title,
    CreatedUserId,
    CreatedDateTime,
    UpdatedUserId,
    UpdatedDateTime
)
SELECT
    Id,
    FitnessStatusId,
    OrgId,
    IsObsolete,
    Code,
    Title,
    CreatedUserId,
    CreatedDateTime,
    UpdatedUserId,
    UpdatedDateTime
FROM sExamination.tOPDFitnessStatus;

-- Example update
UPDATE sExamination.tOPDFitnessStatus_Temp
SET Id = FitnessStatusId; -- Update FitnessStatusId

DROP TABLE sExamination.tOPDFitnessStatus;

CREATE TABLE [sExamination].[tOPDFitnessStatus](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FitnessStatusId] [int] NULL,
	[OrgId] [int] NULL,
	[IsObsolete] [bit] NULL,
	[Code] [nvarchar](50) NULL,
	[Title] [nvarchar](100) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedDateTime] [datetime] NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedDateTime] [datetime] NULL,
PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET IDENTITY_INSERT sExamination.tOPDFitnessStatus ON;

INSERT INTO sExamination.tOPDFitnessStatus
(
    Id,
    FitnessStatusId,
    OrgId,
    IsObsolete,
    Code,
    Title,
    CreatedUserId,
    CreatedDateTime,
    UpdatedUserId,
    UpdatedDateTime
)
SELECT 
    Id,
    FitnessStatusId,
    OrgId,
    IsObsolete,
    Code,
    Title,
    CreatedUserId,
    CreatedDateTime,
    UpdatedUserId,
    UpdatedDateTime
FROM sExamination.tOPDFitnessStatus_Temp;

SET IDENTITY_INSERT sExamination.tOPDFitnessStatus OFF;

DROP TABLE sExamination.tOPDFitnessStatus_Temp;

select * from sExamination.tOPDFitnessStatus
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
select 'ERROR', ERROR_LINE(),ERROR_MESSAGE()
END CATCH