Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts

Friday, March 9, 2012

IIS/MSSQL

I have an SQL 2000 server set up that runs perfectly, and an IIS set up that runs perfectly but I
can not get the webpage to read data from the dbase. Is there a connection that I have to make or a
program I have to load? The page is a .asp page, and when I run the page that should connect
I do not get any errors in the dbase at all, so I can only imagine that it is not even seeing an attempt
at a connection. Any help is appreciated.This page shows how to add a connection to an aspx page, and display the information:
http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=simple
There's also a link to a tutorial which explains how it to do it.

Sunday, February 19, 2012

ignoring keys while Truncating tables

Hello everyone.

I'm working with a customers business application which is developed in MSSQL. The system has over 170 tables and there is no documentation by those who created it. Now the problem is that I have to write script that deletes all the data in all the tables but since there are foreign keys defined in the tables I can't delete the data. Ofcourse I can figure it out eventually by testing back and forth in which order I have to delete the data in the tables but since there are over 170 tables that could take a very long time.

Does anyone now how I can solve this?? is there for examaple a way to make SQL server to ignore the foreign key lookup? What can I do?? is there any way which I can see in what order I should delete the data in the tables?

appritiate any help or comments.

Thanks.

\Homan1. script out your deletes and run the script 170 times, eventualy you will clear out all the tables.

2. use Enterprise Manager to generate a diagram of all the tables in the database. This would tell you the exact order you would need to follow to get everything deleted.

3. in Enterprise Manager and Query Analyzer you can look up the dpendencies of any object. In EM right click on any object, select all tasks, dependencies, in QA press "F8" to show the object browser, select and object drill down till you see dependencies.

4. use sp_depends on all 170 tables/view to figure out the parents and or child relationships.|||If you are going to have to reload the database you are going to want to know your foreign keys.|||For reference of cascade delete refer to SQL TEam (http://www.sqlteam.com/item.asp?ItemID=8595) link.

Refer to this Code (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=641&lngWId=5) and modify to accomplish the task.

HTH|||disable your fk checking before deleting data, and re-enable them after.