SQL delete query
Am using vb 08 and sql 2000; I want sql query that can delete my FileNo column when it's repeated more 10 times in the table. The 11th, 12th, 13th... times shd get deleted. Is it pls possible through vb? Any help, Gurus? Ben
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit ChoudharyPosted Mar 20, 2010, 1:49 AM
get the data by query on the basis of fileID or whatever is common field into a datatable using dataadapter.
Run a loop to DataTable.RowCount and put a condition
if(i>10)
{
//Delete the rows from datatable.
}
Dt.AcceptChanges();
Adp.Update(Dt);
and your records will deleted those are extra other than your 10 reserve records.
Hope it helps.
Please mark as answer if it helps.