SQL2008 db table cleanup

Discussion in 'Databases' started by cis19wcom00, Oct 25, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am viewing tables with mylittleadmin tool and would like to know:

    1. how to delete mutiple tables at once,
    2. how come I am not able to delete the tables with FOREIGN KEY even after deleting the key,
     
  2. ...If you remove any relationship you should be able to.
    Don't you get an error message showing a dependancy?
     
  3. dmitri

    dmitri DiscountASP.NET Staff

    You cannot delete a table probably because it is being referenced by a FOREIGN KEY constraint of some other tables. You need to disable or drop all FK constraints of OTHER tables that reference the victim table before you can drop it.

    To delete multiple tables a once, again, you need, first of all, disable or drop all FK constraints that reference those tables. Connect to your database with Management Studio and open Object Explorer (F8) and Object Explorer Details (F7). In Object Explorer expand your database and click on 'Tables' folder. The tables of your database will be listed in Object Explorer Details. Select multiple tables you want to drop by holding Ctrl key and then hit the 'delete' key.

    You can also drop ALL tables in your database by executing the following stored procedure:

    EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

    The above procedure will drop only the tables that are not referenced by FK constraints. You car execute it repeatedly until all tables are dropped.
     
  4. Thanks Dmitri, I am new to the dotnet world, so please bare with me.
    I am/was using "mylittleadmin" tool provided in SQL manager portion of discountasp, to delete the tables.
    I have Visual studio 2010 and IIS 7 loaded in my computer.
    I was wondering if "management studio" is part of VS 2010 or is it stand alone software? where/how can I get it?
     
  5. dmitri

    dmitri DiscountASP.NET Staff

    Management Studio is part of SQL Server installation. You can get SQL Server Express for free from Microsoft to install in on your local machine. Please follow this link to download and install it. Please choose "Database with Advanced Services."
     
  6. Thanks again Domitiri, I have SQL SERVER 2008 installed in my computer and I launched Management Studio to follow your instructions. It took few moments to set the settings for first time use and then it poped a window to connect to server, and i don't know how to connect to my db hosted by discountasp.net... it is asking for server type with 4 choices, server name etc.... please walk me through to connect.
     
  7. mjp

    mjp

  8. Well, there are drop down menus and I can not type in the iformation provided by discountasp.net.... still waiting for help
     
  9. Thanks this was quite informative. I was wondering if you needed to use sql server 2008 express in between, or youcould directly transfer from sql server 2008 directly to remote site?
     
  10. ...You can transfer tables and records but you may loose relationships with the Wizards at times.
    The best tool is the attach feature in your control panel but be aware it will wipe your current DB clean.
    The next best thing is probably to create scripts then execute them in a SQL window while connected in SQL Server to your remote DB, or use the mylittleadmin, which also allows SQL scripts.
    The data pump wizard in SQL Server works in the Express versions now, it didn't in previous versions.
     
  11. dmitri

    dmitri DiscountASP.NET Staff

    Can you please tell us why you need to delete tables? If you are trying just to clean up your database after unsuccessful installation of a web application, then the recommended method is just resetting your database to its default state. It is much easier and safer to do. Please see this community post for the instructions.
     
  12. Dmitri,
    Thanks for your continued help.

    A) The reason I am deleting tables is because I had installed and using Gallery Server Pro (GSP) before DNN and resetting the DB to its default state will wipe out all tables which GSP had created and contains users information.

    B) I did not know about backing up and resetting the DB till I had both successfully installed GSP and unsuccessfully installed DNN... If I would have known this before attemting to install DNN, I would have backed up and do as you instructed me to.

    C) I wish there were someway of telling which tables are for which application. Right now I am distinushing the tables of different applications by the date installed.

    D) Would you please kindly help me to resolve this issue: http://community.discountasp.net/showthread.php?t=11669
    Thx.
     
  13. dmitri

    dmitri DiscountASP.NET Staff

    When you install DNN, you are given an option to specify "object identifier" or "table prefix" (whatever DNN calls it) that will prefix your tables and other database object such as store procedure and functions with the characters you specify. For example, if you specify object identifier to be 'dnn', then all of your tables names will be in the following form: dnn_tabeleName. If none of your web application that you installed use object identifiers, then you have a high chance of table names collisions which can crash both of your application at either installation or run time. If you can afford reinstalling both of your application, I suggest you to do so by resetting your database to its default state and installing DNN first as it is more complicated and demanding. In other words, please try to install DNN to a clean database.
     
  14. Dmitri Thanks for the info. I am going to delete and reinstall both applications. In doing so I would appreciate your resonse to following questions:

    1. I had few unsuccessful attempted to install DNN... in most cases the Auto (legacy) button was disabled and I was choosing to install at next page of installation of DNN. And in next page I was given the option to add a prefix for table objects and as you were explaining I was adding DNN in front of the table names.... in my only successfull installation of DNN I was given the option to Auto install (legacy) and when Iclicked on it I did not have the option to prefix of DNN to DNN table names.... My question is that when installing DNN should I avoid Auto installation so I have option of adding DNN to DNN tables?

    2. Gallery server pro application, and I think most other applications don't give an option to add special designator to distinguish that tables of application from the others... My question is that if I rename the tables of application with a prefix does it effect the keys and references of other tables to the re-named table?

    3. When installing multiple applications, each application has a web.config file. My question is that, can I have multiple web.config in one site or should I comine them and leave one web.config in root directory?
     
  15. dmitri

    dmitri DiscountASP.NET Staff

    The multiple unsuccessful attempts of installing DNN were probably due to the fact that you were installing it on top of installation files that were already exist on your web server in the installation directory and also on top of the database that already contained objects from previous installation. You need to empty the directory on your web server where you will be installing DNN and reset your database to its defaults.

    Each web application must have its own web.config. Thus if you are installing your DNN to a subdirectory, it will have its own web.config besides the web.config in your root directory. I suggest removing or renaming temporarily you web.config in the root before you install DNN to avoid inheritance conflict.
     
  16. Thanks.

    1. I don't see any web.config in root directory, only web.configs that come with each application in subdirectories. are there hidden files in sever file system?
    2. I am not clear what do you mean by installation files and installation directories? Are you referring to files come under subdirectory when using web application gallery to install applications?
    3. how can I designate a specific prefix to tables name of each application... DNN only allows when installing non-auto version (legacy) and most other application don't give you this option... can I rename the tables after installation? if yes, what happens to references and keys of other tables to the renamed table?
     
  17. dmitri

    dmitri DiscountASP.NET Staff

    Each web application has its own web.config file. If there is no web.config in your root, then no web application is installed in your root.

    Installation directory is the directory where you install application. If you install your DNN to yourdomain.com/dnn, then your installation directory would be /dnn.

    Unfortunately not all web application installer will allow you to specify table prefixes. Changing tables names is not possible because the application will reference them by the original names. Generally speaking, you should use a separate dedicated database for each web application. This is especially true for DNN because it is known to be resources demanding and memory hungry.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page