Sunday, February 19, 2012

How to clear table?

Is there a way to clear all the records in a table in Microsoft SQLServer Management Studio instead of selecting all the rows and delete?

Try the link below and Truncate the table. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms177570.aspx

|||Thanks for the response, but I'm not looking for a code clear records.I am in Microsof SQL Management Studio. How do I clear the table withinthis tool?|||

Assuming no constraint defined on the table try the link below for a walkthrough. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms175491.aspx

|||That instruction only show how to delete a column. Are you suggestingthat deleting the column and then recreate that same column?|||

Sorry wrong link.

http://msdn2.microsoft.com/en-us/library/ms190616.aspx

|||That link shows how to delete the whole tabe. I don't want to deletethe whole table. All I want is to clear all the records in the table. Idon't want to recreate the whole table again.|||Truncate is the clean way to do it or you have to do it by column because a database table is columns with your data in rows so if you don't want to truncate you have to do it by column.|||The reason I asked about clearing the table records is because inphpMyAdmin with MySQL, it is very simple to clear the whole records ina table. I would be very surprise if Microsoft does not have thisfeature in their MS SQL Management Studio tool.|||

MySQL is generally free so you can do crude things but SQL Server cost a lot of money companies will not like data delete operations that cannot be traced. So the links below explain Truncate and Delete very clearly and some solutions using temp table. Hope this helps.

http://codebetter.com/blogs/raymond.lewallen/archive/2005/05/09/62960.aspx

http://www.sql-server-performance.com/q&a118.asp

|||Thanks! I will give those two links some reading.

No comments:

Post a Comment