tailieunhanh - Microsoft SQL Server 2008 R2 Unleashed- P84

Microsoft SQL Server 2008 R2 Unleashed- P84:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 774 CHAPTER 24 Creating and Managing Tables the foreign key constraints that reference a table. Listing shows an execution of this stored procedure for the table in the AdventureWorks2008 database. The procedure results include information about all the constraints on the table. The results to focus on are those that follow the heading Table Is Referenced by Foreign Key. The partial results shown in Listing for the table indicate that FK_StoreContact_Store_CustomerID must be dropped first before you can drop the table. LISTING Using sp helpconstraint to Find Foreign Key References sp_helpconstraint partial results of sp_helpconstraint execution Table is referenced by foreign key FK_StoreContact_Store_CustomerID Two other approaches are useful for identifying foreign key references prior to dropping a table. The first is using a database diagram. You can create a new database diagram and add the table that you are considering for deletion. After the table is added you right-click the table in Object Explorer and select Add Related Tables. The related tables including those that have foreign key references are then added. You can then right-click the relationship line connecting two tables and select Delete Relationships from Database. When you have deleted all the foreign key relationships from the diagram you can right-click the table you want to delete and select Generate Change Script to create a script that can be used to remove the foreign key relationship s . The other approach is to right-click the table in Object Explorer and choose View Dependencies. The dialog that appears gives you the option of viewing the objects that depend on the table or viewing the objects on which the table depends. If you choose the option to view the objects that depend on the table all the dependent objects are displayed but you can focus on the objects that are tables. Using

TỪ KHÓA LIÊN QUAN