• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 118
  • Last Modified:

Deleting sql table

I have a table (20 columns, 140,000 rows). It is imported from an Access database. I want to delete it to re-import it again because some extensive changes in both meta data and row data.

I started running Delete From Table1 but after about 10 minutes, I canceled it thinking I can just execute Drop Table Table1 but this was taking too long as well.

Now I am running Truncate Table Table1 but after 25 minutes it is still running.

Question: What is the best way do delete a table like this?

SQL Server 2012 Express.

BTW, I right-clicked on this table and chose delete option but it wasn't able to drop it.
0
Mike Eghtebas
Asked:
Mike Eghtebas
2 Solutions
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
There is some process accessing the table at the same time you are trying to delete it?
Check for everything (SQL commands, Reindex jobs, backup jobs, replication, etc...)
0
 
Vikas GargBusiness Intelligence DeveloperCommented:
It might be the case that the query still running having involvement of the same table.

Find that query kill that

then you will be able to delete or drop the table

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
WHERE sqltext.TEXT LIKE '%tABLENAME%'

While running above query if you find any query which is running for long time it can be killed using following command.

KILL [session_id]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now