Unix Technical Forum

delete last added row -how to

This is a discussion on delete last added row -how to within the SQL Server forums, part of the Microsoft SQL Server category; --> hi i have a question how can i delete last added row. I have 2 tables . source and ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:25 AM
Marcin Wolku
 
Posts: n/a
Default delete last added row -how to

hi i have a question how can i delete last added row. I have 2 tables .
source and destination . I take a 1 row from source table , do some
operation on it and save to destination table . after succesfull written I
want to delete added row from source table.. i'm using a coursors. the main
problem is : is there any function to check which row was last added. Now I
am doing it using select * from destionation where (and necessary
conditions). but if destination table will be 100000000 rows for example it
takes too much time... Is there another possibility to do it ???
please help

Marcin Wolku
wolku


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:25 AM
Marcin Wolku
 
Posts: n/a
Default Re: delete last added row -how to

One important think both tables don't have primary key

Użytkownik "Marcin Wolku" <wolku@epf.pl> napisał w wiadomości
news:42805b7b@news.vogel.pl...
> hi i have a question how can i delete last added row. I have 2 tables .
> source and destination . I take a 1 row from source table , do some
> operation on it and save to destination table . after succesfull written I
> want to delete added row from source table.. i'm using a coursors. the
> main problem is : is there any function to check which row was last added.
> Now I am doing it using select * from destionation where (and necessary
> conditions). but if destination table will be 100000000 rows for example
> it takes too much time... Is there another possibility to do it ???
> please help
>
> Marcin Wolku
> wolku
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:25 AM
David Portas
 
Posts: n/a
Default Re: delete last added row -how to

Unless you can identify the last inserted row by some column or columns
in the table you cannot delete that row. There is no special feature
for determining the insertion order.

The most important problem you have is the lack of a primary key. Why
don't you fix this? This is a fundamental design flaw as I hope you
know.

--
David Portas
SQL Server MVP
--

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:15 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com