Solved

Increasing Identity length in sql server

Posted on 2016-12-01
4
35 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
  • 2
  • 2
4 Comments
 
LVL 65

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 65

Accepted Solution

by:
Jim Horn earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now