How to delete rows by calling its row number

I have this data stored in the SQL Server

enter image description here

How can I delete the first three rows by calling the row number found in the left (1,2,3)?

>Solution :

You can’t. That row number is not tangible and is nothing more than the order the results were returned in. SQL does not guarantee order of data, so there is no rule that says if you run the same query 20 times, you’ll get the same results at 1,2, and 3 each time. That’s not to say you won’t get them same results, they’re just not guaranteed. You need to delete using a column that actually exists as part of the table definition, such as F1, F2, etc…

As others have suggested in the comments, try to clean up the data before you import it into SQL Sever. You have a few options.

  1. Delete the rows from the file before importing.
  2. Configure the Import Wizard correctly to exclude those rows.

Helpful link

Leave a Reply