Solved

Increasing Identity length in sql server

Posted on 2016-12-01
4
16 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
Comment Utility
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
Comment Utility
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
Comment Utility
>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
Comment Utility
Thanks Jim, I didn't want to run into any issues later.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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 …
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

743 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

17 Experts available now in Live!

Get 1:1 Help Now