Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Other SQL Server Topics / June 2007

Tip: Looking for answers? Try searching our database.

Forcing an IDENTITY column to have a certain value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Weyus - 27 Jun 2007 21:11 GMT
All,

Is there any way to _set_ an IDENTITY column to have a certain value
so as to create a gap in the set of identity values on purpose?

All I've found is SET IDENTITY_INSERT.

Thanks,
Wes
Marcin A. Guzowski - 27 Jun 2007 21:28 GMT
> All,
>
> Is there any way to _set_ an IDENTITY column to have a certain value
> so as to create a gap in the set of identity values on purpose?
>
> All I've found is SET IDENTITY_INSERT.

There is also a DBCC command:
DBCC CHECKIDENT ('table_name', reseed, new_value)

Signature

Best regards,
Marcin Guzowski
http://guzowski.info

Weyus - 27 Jun 2007 22:02 GMT
On Jun 27, 3:28 pm, "Marcin A. Guzowski"
<tu_wstaw_moje_i...@guzowski.info> wrote:
> > All,
>
[quoted text clipped - 9 lines]
> Best regards,
> Marcin Guzowskihttp://guzowski.info

Thanks,
That's what I needed!

Wes
Gert-Jan Strik - 28 Jun 2007 20:31 GMT
If you only need small gaps, you could simply do this:

 BEGIN TRANSACTION
 
 INSERT INTO my_table DEFAULT VALUES
 
 ROLLBACK TRANSACTION

HTH,
Gert-Jan

> All,
>
[quoted text clipped - 5 lines]
> Thanks,
> Wes
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.