Is it possible to delete the 'first' record from a table in SQL Server
, without using any WHERE
condition and without using a cursor?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
Define "First"? If the table has a PK then it will be ordered by that, and you can delete by that:
If the table has no PK, then ordering won't be guaranteed...
What do you mean by «'first' record from a table» ? There's no such concept as "first record" in a relational db, i think.
Using MS SQL Server 2005, if you intend to delete the "top record" (the first one that is presented when you do a simple "*select * from tablename*"), you may use "delete top(1) from tablename"... but be aware that this does not assure which row is deleted from the recordset, as it just removes the first row that would be presented if you run the command "select top(1) from tablename".