?
Solved

Increasing Identity length in sql server

Posted on 2016-12-01
4
Medium Priority
?
64 Views
Last Modified: 2016-12-01
I have a table in my SQL that currently has 900+ records and I noticed that the ID length is 4. I'm worried that when it reaches 9999 it will give me error and no longer write data.

How do I increase the length?

I know that I can reset the seed with "DBCC CHECKIDENT ([WIP], RESEED, 0); GO" however that will cause duplicates.
0
Comment
Question by:Jaime Martinez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 41909448
Just for kicks and giggle generate the CREATE TABLE schema for this table and paste it into this question.

In SSMS, click on table, right-click > Script Table As > Create To > New Query Editor Window
0
 

Author Comment

by:Jaime Martinez
ID: 41909461
Jim here is the schema

USE [UE_Internal]
GO

/****** Object:  Table [dbo].[WIP]    Script Date: 12/1/2016 2:48:26 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[WIP](
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [CompID] [nvarchar](255) NULL,
      [ShipStatus] [nvarchar](243) NULL,
      [Factory] [nvarchar](255) NULL,
      [OrdNumber] [nvarchar](255) NULL,
      [OrdCust] [nvarchar](255) NULL,
      [OrdPO] [nvarchar](255) NULL,
      [OrdState] [nvarchar](255) NULL,
      [OrdWhse] [nvarchar](255) NULL,
      [OrdStartShip] [datetime] NULL,
      [OrdCancelDate] [datetime] NULL,
      [OrdProdID] [nvarchar](255) NULL,
      [OrdProdDesc] [nvarchar](255) NULL,
      [OrdProdQTY] [nvarchar](255) NULL,
      [OrdStyleNotes] [ntext] NULL,
      [PrdOrdDate] [datetime] NULL,
      [PrdBuyNote] [nvarchar](255) NULL,
      [PrdPiDate] [datetime] NULL,
      [PrdTesting] [nvarchar](255) NULL,
      [PrdTestingState] [nvarchar](255) NULL,
      [PrdTestingDate] [datetime] NULL,
      [PrdInnerLabel] [nvarchar](255) NULL,
      [PrdHangtags] [nvarchar](255) NULL,
      [PrdCareLabels] [nvarchar](255) NULL,
      [PrdPriceTickets] [nvarchar](255) NULL,
      [PrdPriceTicketsOrdDate] [datetime] NULL,
      [PrdPriceTicketsSentDate] [datetime] NULL,
      [PrdPriceTicketsTracking] [nvarchar](255) NULL,
      [PrdDeliveryDate] [datetime] NULL,
      [ItsNumber] [nvarchar](255) NULL,
      [ItsEta] [datetime] NULL,
      [ItsVessalDate] [datetime] NULL,
      [ItsInHouseDate] [datetime] NULL,
      [ItsReference] [nvarchar](255) NULL,
      [ItsContainer] [nvarchar](255) NULL,
      [ItsArriveDate] [datetime] NULL,
      [VpoNumber] [nvarchar](255) NULL,
      [PP] [datetime] NULL,
      [PhotoSamples] [datetime] NULL,
      [2ndPP] [datetime] NULL,
      [Top] [datetime] NULL,
      [WipNotes] [ntext] NULL,
      [ReadyOrPending] [nvarchar](510) NULL,
      [ReworkVendor] [nvarchar](510) NULL,
      [WIPStatus] [nvarchar](510) NULL,
      [ToWhse] [nvarchar](510) NULL,
      [WhseNote] [nvarchar](510) NULL,
      [Field1] [nvarchar](510) NULL,
      [Field2] [nvarchar](510) NULL,
      [Field3] [nvarchar](510) NULL,
      [Field4] [nvarchar](510) NULL,
      [PPAprroved] [datetime] NULL,
      [TopApproved] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 41909464
>I'm worried that when it reaches 9999 it will give me error and no longer write data.
>      [ID] [int] IDENTITY(1,1) NOT NULL,
Since ID is an int it will continue incrimenting by 1 until the max allowable value for an int data type = 2,147,483,647

So, no 9999 issues.
0
 

Author Closing Comment

by:Jaime Martinez
ID: 41909490
Thanks Jim, I didn't want to run into any issues later.
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question