Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SP's...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-17 : 08:27:15
Biju writes "I need to write a SP that would do the following:

1. A way to input the database & table name at the onset.
2. A way to delete 'N' number of customers from 'N' number of tables in 1 go.

Note: All of the above should be taken care off by 1 SP.

Is it possible? Help in any/all of the 2 cases required. An early response will be highly appreciated.

Thanks.

Biju."

nr
SQLTeam MVY

12543 Posts

Posted - 2003-12-17 : 08:32:54
create procedure mysp
@dbname varchar(128) ,
@tablename varchar(128)
as

...
use dynamic sql
go

For the second case input a csv string of tables and use a function or inline code to populate a temp table from it then loop through the temp table for the deletes (in a transaction).


Beware of what you are trying to do though. The user will need permission on the tables and do a search for sql injection.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -