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)
 Deleting a list of records

Author  Topic 

evanburen
Posting Yak Master

167 Posts

Posted - 2008-01-03 : 09:46:36
I often have to delete a long list of records and given the CompID for each value which is an int value and the PK. I'm not sure how to do this as the only ways I know how aren't working. Could someone give me some pointers? Thanks


CREATE PROCEDURE [dbo].[sp_DeleteRetiredCompanies]

@CompID Int

AS

DELETE FROM TCompanies WHERE CompID IN (@CompID)
DELETE FROM TCompanyProfiles WHERE CompID IN (@CompID)
DELETE FROM TCEOComp WHERE CompID IN (@CompID)
DELETE FROM Relationships WHERE CompID IN (@CompID)

GO


exec sp_DeleteRetiredCompanies '12931,12845,14551'

error - interprets compID values as strings

exec sp_DeleteRetiredCompanies 12931,12845,14551

error - too many arguments specified

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-03 : 09:49:06
See this:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6134
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-03 : 09:52:44
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

evanburen
Posting Yak Master

167 Posts

Posted - 2008-01-03 : 10:08:41
Very helpful - Thanks a lot.
Go to Top of Page
   

- Advertisement -