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 2005 Forums
 SQL Server Administration (2005)
 Select Data and Delete only the selected data

Author  Topic 

beza
Starting Member

16 Posts

Posted - 2009-04-05 : 04:51:40
Hey

I would like to know how can I write a stored procedure that selects data from a table and afterward deletes only the data selected..

any help would be appreciated.
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-06 : 05:51:42
quote:
Originally posted by beza

Hey

I would like to know how can I write a stored procedure that selects data from a table and afterward deletes only the data selected..

any help would be appreciated.
Thanks


Like this

create procedure test
(
@parameter varchar(10)
)
as
select columns from your_table
where col=@parameter

delete from your_table
where col=@parameter


Madhivanan

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

- Advertisement -