December 13, 2011 at 7:51 am
Hi,
I want to auto increment my ID field.. Is there any option Like Auto - Increment in SQL Server Management Studio Express.
Thanks
December 13, 2011 at 7:55 am
Are you designing a table in the GUI? If so, set the column to an Identity. You do that in the Column Properties at the bottom of the screen. Expand the Identity Specification and set Is Identity to "Yes".
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 13, 2011 at 7:56 am
in SQL, that's the IDENTITY() property;
you can script it like this:
CREATE TABLE MYTABLE(
ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
OtherCollumns varchar(30 )
if you have SSMS for SQL Express, you can design the table and add the property there too.
Lowell
December 13, 2011 at 8:04 am
Thank u so much Gsquared.. Appreciate that..
December 13, 2011 at 8:05 am
You're welcome.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 14, 2011 at 12:43 am
Hi,
For the first time when i run the query it is counting from 1 to n..
Next time when i run the console once again and execute the query, my id Value is not counting from 1, It is counting from n(previously where it is stopped) and incrementing thereafter...
How to resolve this one ??
Thanks
December 14, 2011 at 12:58 am
ns22boss (12/14/2011)
Hi,For the first time when i run the query it is counting from 1 to n..
Next time when i run the console once again and execute the query, my id Value is not counting from 1, It is counting from n(previously where it is stopped) and incrementing thereafter...
How to resolve this one ??
Thanks
SET IDENTITY_INSERT [ database_name . [ schema_name ] . ] table { ON | OFF }
As a side note you should avoid IDENTITY INSERTs. IDs should not be used for sequencing. There is ORDER BY clause for it.
December 14, 2011 at 1:01 am
Hi Dev,
Should i write this Query inside Java Source or in SQL query pane when i execure the query ???
Thanks
December 14, 2011 at 1:04 am
ns22boss (12/14/2011)
Hi Dev,Should i write this Query inside Java Source or in SQL query pane when i execure the query ???
Thanks
I guess you missed the part which I added later.
'As a side note you should avoid IDENTITY INSERTs. IDs should not be used for sequencing. There is ORDER BY clause for it. '
December 14, 2011 at 1:11 am
Hi Dev,
But i want the ID column should start from 1 and counts till there is no Record in Excel sheet. Since i am using Server Management Studio Express, by setting the Identity Specification value to 1 and every time i need to change the value, when i run the Java Console.
So i need to get rid of this one..
Pls help on this
December 14, 2011 at 1:50 am
Hi,
If i understand it correctly you want to restart the identity counter?
See this: http://msdn.microsoft.com/en-us/library/ms176057.aspx
You can reseed the table to achieve what you are after.
Thanks,
Simon
December 14, 2011 at 4:15 am
Hi,
It works fine if i use this query DBCC CHECKIDENT ( <table_name>,RESEED,<value>)
Thanks for all for your repsonse.
sathish.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply