473,461 Members | 1,361 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to generate autonumber column in a table?

Hello

I create a table name emp as following

crate table emp
(
empno int primary key,
Ename varchar(20)
)
now i want to when i insert record in this table
the empno should generat by itself
with out using identity.
it means how to generate autonumber minualy.

thank you in advance everyone.
Jun 16 '10 #1
1 1606
hi dear

if u are using sql database then
u can autogenerate number in ur primary key by following code..

CREATE TABLE [dbo].[emp](
[empno] [int] IDENTITY(1,1) NOT NULL,
[Ename] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_emp] PRIMARY KEY CLUSTERED
(
[empno] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]



above code ur empno will increment by 1 autogenerated automatically
Jun 16 '10 #2

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

Similar topics

11
by: Peter Foti | last post by:
Hi all, I have a form that contains a 2 column table. In the left column is the description for a particular input (ie - "First Name", "Last Name", "Phone Number", etc.). In the right column...
5
by: jonhanks | last post by:
I'm trying to copy a table and its structure from DBase into Access. One of the fields is a primary key and contains numbers from 0 to 20000 and then from 30000 to 40000. How can I make this...
2
by: sea# | last post by:
I implemented article "Inserting relational data using DataSet and DataAdapter" from this link: http://www.codeproject.com/cs/database/relationaladonet.asp In my code. It has a perfect...
2
by: Reddy | last post by:
Hi, I am inserting records into a table having a autonumber column(ID) as primary key. I get the value of ID by using select Max(ID) from table. Is there any way to retieve the value immediately...
1
by: Simon Abolnar | last post by:
How can I add autonumber column in ASP.NET datagrid? Example: 1 | data 2 | data 3 | data Thanks for help! Simon
2
by: Hymer | last post by:
Hello, I have a small two-column table with three rows. The first column has a logo and the second column has the name of the organization. The logo's in the first column are too high. That...
5
by: Hymer | last post by:
Hello, I have a small two-column table with three rows. The first column has a logo and the second column has the name of the organization. The logo's in the first column are too high. That...
10
by: ste | last post by:
Hi there, I'm trying to query a MySQL database (containing image data) and to output the results in a HTML table of 3 columns wide (and however many rows it takes) in order to create a basic...
1
by: akress | last post by:
Hiya, I'm trying to convert a table with 6 colums that looks like this: <table class="myTable" width="640px"> <tr> <td><a href="#"> <img src="../_img/announce.gif" align="middle"...
2
by: shiznaw | last post by:
So, umm. How would you generate an alpha-numeric autonumber each time an end user clicks a field/button on a form without using the autonumber option within a table.
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.