| | |
Deletion
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
If your schema is a good one the "8th" row will be uniquely identified by it's primary key so to delete a single row in a table you would use syntax like:
You need to replace <table> with the table name obviously and <primary key column> with the column name and then <value> would be whatever the unique value is in primary key column of the 8th row of your table.
Example:
----------------------------------------
mytable |
----------------------------------------
pkID int | dbData varchar(50)|
----------------------------------------
1 |Hello |
2 |Goodbye |
.
.
.
8 |Go away |
----------------------------------------
so to delete the 8th row my TSQL would be:
Simple really.
MS SQL Syntax (Toggle Plain Text)
DELETE FROM <table> WHERE <primary KEY column> = <value>
You need to replace <table> with the table name obviously and <primary key column> with the column name and then <value> would be whatever the unique value is in primary key column of the 8th row of your table.
Example:
----------------------------------------
mytable |
----------------------------------------
pkID int | dbData varchar(50)|
----------------------------------------
1 |Hello |
2 |Goodbye |
.
.
.
8 |Go away |
----------------------------------------
so to delete the 8th row my TSQL would be:
MS SQL Syntax (Toggle Plain Text)
DELETE FROM mytable WHERE pkID = 8
Simple really.
•
•
Join Date: Jul 2005
Posts: 483
Reputation:
Solved Threads: 19
the way you want to do it, I don't know of a way without knowing the criteria you are sorting by and the table schema.
if you have a primary key and are sorting by that primary key,
example table customer with primary key customerid,
you could do this
if you have a primary key and are sorting by that primary key,
example table customer with primary key customerid,
you could do this
MS SQL Syntax (Toggle Plain Text)
DELETE FROM customer WHERE customerid = (SELECT top 1 c.customerid FROM (SELECT Top 8 customerid FROM customer ORDER BY customerid ASC) c ORDER BY c.customerid DESC)
![]() |
Similar Threads
- Prevent a registry key from deletion (C#)
- passwords (Web Browsers)
- 100% CPU Usage - No Virus, No gaming (Windows NT / 2000 / XP)
- Unknown Bootup Command (Windows NT / 2000 / XP)
- Faulty default homepage (Web Browsers)
- PC stuck. 100% CPU usage. (Windows NT / 2000 / XP)
- http://scrk.com/passthrough/index.html? HELP !!! (Web Browsers)
Other Threads in the MS SQL Forum
- Previous Thread: ASP.Net VB Page to update a users profile not updating.
- Next Thread: sql 2005 to sql 2000
| Thread Tools | Search this Thread |






