By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

auto generate number in which is auto add in sql server table with other data

P: 1
I have project in with sql server backend.
i want to auto generate a number for particular column.
with the auto generated number i want to insert some other data in the same row same table. on button click event.

railway PNR no.:- want to autogenerat
passenger details:- want to inserted simultaneously

pls help me
Mar 30 '11 #1
Share this Question
Share on Google+
2 Replies

P: 107

Using SQL Server - In Table Design Set that "PNRNo" Column as Primary Key and Set IsIdentity=Yes

At the End of your Insert query Add the Following Line

Expand|Select|Wrap|Line Numbers
  1. Select @@identity;
- This Will Return the PNRNo Value. Using this value you can use the update query.

If this is not the answer you expected, Post your Code here.

Mar 30 '11 #2

P: 7
1. for PNR column choose data type numeric.

2. Go to Column properties window and expand Identity specification option.

3. Where it is written Is Identity select yes.

4.In the same menu you can also provide Identity increment for how much it increments every time e.g. If you want to increment value by 1 number every time data is recorded put value 1.

5. you can also set starting seed so that you don't have to do that manually. e.g. put 101 if you want first record should have pnr no = 101
Mar 31 '11 #3

Post your reply

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