| Author: Nagarajan.L 20 Aug 2008 | Member Level: Gold | Rating:  Points: 6 |
Hi, we can do all in one sp. i given one sp below for sample.
sp :
create procedure allInOne @action char(1), @id int=null, @name nvarchar(50)=null
as
if(@action='I') begin insert into tblTest (id,name) values(@id,@name) end else if(@action='U') begin update tblTest set name=@name where id=@id end else if(@action='D') begin delete from tblTest where id=@id end
here tblTest is a table Name. and action parameter if i means Insert U means Update D means Delete
i take two field in my example id and name. now i hope u can do ur need usig this example.
thanks Nagarajan.L
|
| Author: vipul 20 Aug 2008 | Member Level: Diamond | Rating:  Points: 5 |
hi, it is possible but it is complicated you have to check variable to perform operation like this way.
create procedure test ( @Action varcahr(10) // From the c# code you passed 'Insert', 'Update', 'Delete' //then Your Data to pass for insert but here allow null @column1 varchar(50)=null, @cloumn int =0 ) as begin if @Action = 'Insert' begin // insert data end else if @Action = 'Update' begin // update data end else if @Action = 'Delete' begin // Update Data end end
vipul, http://dongavipul.blogspot.com
Please Rate This Answer If They Helpful
Thanks & Regards Patel Vipul
|