473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to set and reset column identity by a query?

nirmalsingh
218 100+
hai all,

table : country
primary key: country_id (identity not set)

my question is.

i want to change country_id property to set identity, and insert a record and then i want to release identity (identity set=off).
how to write a query for it?
thanx in advance.
Regards Nirmal
Feb 29 '08 #1
1 2340
ck9663
2,878 Expert 2GB
hai all,

table : country
primary key: country_id (identity not set)

my question is.

i want to change country_id property to set identity, and insert a record and then i want to release identity (identity set=off).
how to write a query for it?
thanx in advance.
Regards Nirmal

Option 1:
1. Alter your table to set identity property to country_id.
2. Insert the record.
3. Alter the table back to remove identity.

Option 2:
1. Use IDENTITY() function in SELECT INTO to create a new table.
2. Inspect the new table.
3. Truncate your current table
4. Insert the new table to your current one
5. Drop your new table

Option 3:
If you only need something sequential:
Try this

Happy coding

-- CK
Feb 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gunnar Vøyenli | last post by:
Hi (SQL Server 2000) I have an existing table (t) with a column that is NOT an identity column (t.ID), but it has manually inserted "row numbers". I want to make this column become an identity...
2
by: Ryan P. Kennedy | last post by:
Reset the Identity Increment Hello: I have a table with a bigint type column (field) that has an identity seed of 1 and an identity increment of 1. The column is the primary key for the...
2
by: Dave | last post by:
I cannot insert into my appointments table because the primary key and identity column, appt_id, cannot be added. What do I have to change in my SQL statement to add new records into this table? I'm...
6
by: Who.Really.Really.Cares | last post by:
Hi! I guess this must be a FAQ but I'll give it a try. I've searched the web and usenet archive and found only negative answers. But most of them were dated like 3-4 years back. Hasn't anything...
3
by: mal_k100 | last post by:
Hi All, 1. Created table in SQL Server 2K with Primary key as int Identity 2. Link to table in MS Access 2K 3. Using form in MSAccess to update the linked table I want SQL server to...
2
by: DerekF | last post by:
Reset the Identity Increment -------------------------------------------------------------------------------- Reset the Identity Increment Hello: I have a table with a bigint type column...
0
by: cmgarnett | last post by:
I am trying to reset an IDENTITY RowNumber back to 1 in a query when the Person's Name is the same. The following query can be used agains the pubs database in SQL Server. I am trying to...
1
rsrinivasan
by: rsrinivasan | last post by:
Hi all, I have a table with one identity column. I want to reset that column from 0(zero). How can i achive it. Thanks,
0
by: Frank Swarbrick | last post by:
>>On 6/10/2008 at 4:30 PM, in message <ebf88f96-d8b0-4dfc-85ed-a3a5c44ae4dd@i18g2000prn.googlegroups.com>, <anuritab@gmail.comwrote: Seems like that would work, unless you are actually using a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.