Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I did a mistake in previous question please check this

see if i have a database like this

Table Headers Category City Serial_no

Table Content Dealer Agra 1
Dealer Agra 2
Dealer Chennai 3

Now when i add another record Dealer Agra 3

Then the table content should change to

Dealer Agra 1
Dealer Agra 2
Dealer Agra 3
Dealer Chennai 4

This should be achieved without using auto id

please help me....
Posted
Comments
Wendelius 6-Sep-11 3:00am    
No need to repost to correct the error. Delete this and use "Improve question" action in your original question to modify it.
Pravin Patil, Mumbai 6-Sep-11 3:35am    
Follow this :
declare @count int
select @count = select count(*) from YourTableName

Insert into YourTableName
values
(
"Dealer"
,"Agra"
,@count + 1
)

This should insert new row with appropriate id. I hope this address your issue. and as mika said, do not repost the same question.

1 solution

Try:
SQL
SELECT iD, ROW_NUMBER() OVER (ORDER BY iD) from myTable
The ROW_NUMBER function gives you a row number starting with one and increasing for each row in the result set.
 
Share this answer
 
Comments
M.Ravibalaji 6-Sep-11 4:15am    
i am using access database can you give the query for that
OriginalGriff 6-Sep-11 4:29am    
I don't use Access, so I can't help directly. Have a look here: http://www.tek-tips.com/viewthread.cfm?qid=1615753&page=1 which appears to be doing what you want in Access.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900