943,949 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 1156
  • MS SQL RSS
Nov 17th, 2008
0

Having Two Auto Numbers..

Expand Post »
Hi Fellows,
Well. let me start by higlighting the problem i face.I have two columns namely PID which is the primary key and also a auto number.The second is Serial No. which is also a auto number.

The problem i face is that when i submit my form spcifying a month i want my serial no. to start from one and and end with the number of records in my Datagrid.

IF i come to the same and select a different month the PID should continue from where the last auto no. is but my serial no should start from 1 again..

Is there any option to do like this.Both PID and Serial No. are in the same table.


Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
bharathi_n_r is offline Offline
25 posts
since Jan 2008
Nov 17th, 2008
0

Re: Having Two Auto Numbers..

You can set a trigger on Insert Button as check the month for inserting record and previous record. It both are different then reset Serial No. and then insert.

Or

Click of submit button check the month of previous record and reset the Serial No. and the execute the insert command.
Reputation Points: 10
Solved Threads: 9
Junior Poster
sierrainfo is offline Offline
144 posts
since May 2008
Nov 17th, 2008
0

Re: Having Two Auto Numbers..

Thanks man,
I just checked it out... Sql wont allow me to have two auto no's.Is there any other option in code to do this and how to reset serial no to one without deleting the data.
I am using vb.net 1.1
Reputation Points: 10
Solved Threads: 0
Light Poster
bharathi_n_r is offline Offline
25 posts
since Jan 2008
Nov 17th, 2008
0

Re: Having Two Auto Numbers..

Fellows,
I have found another option to do this(via Code).Instead of checking the month while submitting, i have found a way to count the number of rows using the dataset property
MS SQL Syntax (Toggle Plain Text)
  1. dsEmployee.TABLES(0).Rows.Count

It is returning me the number of rows in my datagrid.I will write a for loop and form an ary to start from one and increment it till the last row of datagrid...Thanks for the replies..I hope some one will use this...

Thanks and Regards
Reputation Points: 10
Solved Threads: 0
Light Poster
bharathi_n_r is offline Offline
25 posts
since Jan 2008
Nov 17th, 2008
0

Re: Having Two Auto Numbers..

If Data is so large it will affect the performance due to For Loop

Thanks
Bye.
Reputation Points: 10
Solved Threads: 9
Junior Poster
sierrainfo is offline Offline
144 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: the difference between Stored procedures temporary tables
Next Thread in MS SQL Forum Timeline: Backup Transaction log and BLOG





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC