February 20, 2024 at 8:40 am
Alter table query to change identity column from int to bigint in sql2019 server
February 20, 2024 at 9:09 am
have a large Table having Identity column as Int and value has neared the max value so need to make the identity column as BigInt
February 20, 2024 at 9:15 am
Is it so difficult for you to ask a question?
Can anyone provide the T-SQL code I need to amend an identity column from INT to BIGINT, please?
I am guessing that this is what you are asking. If not, what are you hoping for?
February 20, 2024 at 9:22 am
Yes
February 20, 2024 at 9:25 am
DROP TABLE IF EXISTS #SomeData;
CREATE TABLE #SomeData
(
SomeId INT IDENTITY(1, 1)
,SomeText VARCHAR(10)
,CONSTRAINT PK_Nonsense
PRIMARY KEY CLUSTERED(SomeId)
);
ALTER TABLE #SomeData DROP CONSTRAINT IF EXISTS PK_Nonsense;
ALTER TABLE #SomeData ALTER COLUMN SomeId BIGINT;
ALTER TABLE #SomeData ADD CONSTRAINT PK_Nonsense PRIMARY KEY(SomeId);
February 20, 2024 at 9:36 am
Thanks Phil
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy