Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 working operations on rows on event fire

Author  Topic 

scottichrosaviakosmos
Yak Posting Veteran

66 Posts

Posted - 2010-06-24 : 06:31:02
I have a a grid on my asp.net page and grid has a delete link by which i delete a row from grid so as database with rowdelete event of grid using one id as uniquecolumn and rows on the basis of this column. now this unique colum is like uq00001/1 and its varchar. i want that when i delete one row from grid for example grid has 5 rows and i am deleting 3rd row so in database the unique id ll be like uq0001/1,uq0002/2,uq0003/3.. nowif i delete third row from grid then the row ll ve deleted from database and the other ids after these ll be adgested. eg. when thrid row is deleted then the 4rth row ll become uq0003 and 5th ll become uq004.. like wise i have to do to increment also when add row in grid. but deletion is where i am stucked in .
and i want to do this through database. i have tried cursor inside a stored procedure but its not working.
And no sugestions please because i have to achive this task to use this in some other purpose also .so dont reply as this is not needed or better do something else. I need a technical solution to the abouve problem and not whether i should go this way or not.
Thank you

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-24 : 08:06:26
An ID should never change its value. Maybe there is another table that links to that ID then there comes up a lot of confusion if the value is changing.

If your need is for presentation only then generate an "displayID" in your front end each time you are displaying the retrieved data.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-24 : 08:43:04
How many rows are in that table?
If you have records from 'uq0001' to 'uq9999' and you have deleted 'uq0002' then all rows greater than 'uq0001' should be updated with a new value?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-06-24 : 08:51:01
I would like to ask one more thing.
Are you allowing multiple deletes?


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

scottichrosaviakosmos
Yak Posting Veteran

66 Posts

Posted - 2010-06-24 : 11:47:38
no i am only allowing single delete not multiple delete . in click a single row is deleted.





quote:
Originally posted by Idera

I would like to ask one more thing.
Are you allowing multiple deletes?


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH



scoo
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-06-25 : 01:59:28
You can do something like this.
Create a trigger which updates all the id's with -1 whose value is greater than the Id that has been currently deleted.



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page
   

- Advertisement -