Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Generate Delete Stored Procedure

By jbohanon,

This procedure will generate a delete stored procedure against a provided table and column name in your database.  It will search for foriegn key constraints and create a delete statement for each one found in the database.  The procedure has three parameters:
@table_name nvarchar(128) = the name of the source table
@column_name nvarchar(128) = the name of the source column
@new_proc_name nvarchar(128) = the name of the new procedure that will be generated.

Output the results from this procedure to text (or file) and then copy the results in order to create the procedure. 

Please study the resulting delete statements to make sure that they do not violate the rules of your database.

Total article views: 251 | Views in the last 30 days: 1
 
Related Articles
FORUM

Identifying ASCII characters in NVARCHAR columns

Identifying ASCII characters in NVARCHAR columns

FORUM

FK selection (an nvarchar(30) column or four int columns)

FK selection (an nvarchar(30) column or four int columns)

ARTICLE

Dynamic creation of Insert, Update, Delete Stored procedures

Automates the creation of INSERT, UPDATE & DELETE stored procedure of a table

ARTICLE

Automatically Generate Stored Procedures

This article will show you how to automatically generate insert, update, and delete procedures for t...

FORUM

Can I encrypt ntext and nvarchar(max) columns ?

Can I encrypt ntext and nvarchar(max) columns ?

 
Contribute