Hi,
This is the query which is helpful to find in ur database which tables are foregin keys and which having Primary key
SELECT
DISTINCT
Constraint_Name AS [Constraint],
Table_Schema AS [Schema],
Table_Name AS [TableName]
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
GO
Now This is the Stored Procedure which can delete ur table records
CREATE PROC USP_DeleteDataFromTables
(
@TName Varchar(50)
)
AS
DECLARE @Query NVARCHAR(50)
SET @Query ='DELETE FROM '+@TName
EXEC (@Query)
GO
Here when u execute this stored procedue u have to just send a paramater value for ur table name for example u have employee_master table so u wright
EXEC USP_DeleteDataFromTables 'Employee_Master'
Now automatically when u press F5 all data will be removed from that table.
if u want any more suggestion u can contact me on sourabh_mishra1@hotmail.com
Sourabh Mishra
Rama Sagar, if this helps please login to Mark As Answer. | Alert Moderator