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
 Transact-SQL (2000)
 Executing SPs in a 'test mode'

Author  Topic 

adjones1980
Starting Member

36 Posts

Posted - 2007-07-20 : 04:32:38
I have a stored proc that I want to test before using it... i.e. see if I get the right affected record count on a number of DELETE statement in SP. I don't want to run it and it only to partially work because I might loose the parent table records, which will leave child records unfindable in the child tables.

Is there anything like that in SQL Server 2000?

Sorry if this is in the wrong forum.

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-07-20 : 06:52:28
1. start with a select statement.
if it returns the number of records you expect, convert the select into a delete (if can be done quite simply)

2. before the delete....put in a "begin transaction".
execute the code in QA....if the number of records deleted match ywhat you expect...you can put in a COMMIT TRANSACTION...otherwise put in a ROLLBACK TRANSACTION


Read up more on BEGIN/COMMIT/ROLLBACK TRANSACTION


Also.....you should not be able to execute anything that could delete parent records before child records...unless you do NOT have constraints enabled in your database...in hwich case you need to read up on foreign keys and constraints.
Go to Top of Page
   

- Advertisement -