Solved

Increasing Identity length in sql server

Posted on 2016-12-01
4
52 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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.

740 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