Hi
alter procedure dbo.delete_nod
@table_name nvarchar(255),
@pk_fld_id nvarchar(255),
@pk_value numeric,
@project_id numeric
AS
declare @delete_tree_node bit
Begin
select @delete_tree_node = isnull(delete_tree_node,0)
from projects where project_id = @project_id
End
print @table_name
if (@table_name ='State' and @pk_fld_id = 'State_Id' and @delete_tree_node = 1)
Begin
Begin Transaction
Begin
delete from mytable where id in(select id from table1 where rid in(select rid from
table2 where sid in(select sid from table3 where tid = @pk_value )))
End
if @@error <> 0
Begin
goto Error_Routine
End
-- I have multiple delete statements here
Commit Transaction
End
Return
Error_Routine:
Rollback Transaction
GO
delete_tree_node 'Class','Id',6177,20
when I run this procedure with above parameters it takes long time to run. I am checking the condition if the parameter is state then only go to deletes block. but here I am passing class it takes so long time to print the variable. if I commented out the deletions block, it executes in 0 seconds. Why it is taking so much time to execute when I don't pass State.
Any help would be appreciated
alter procedure dbo.delete_nod
@table_name nvarchar(255),
@pk_fld_id nvarchar(255),
@pk_value numeric,
@project_id numeric
AS
declare @delete_tree_node bit
Begin
select @delete_tree_node = isnull(delete_tree_node,0)
from projects where project_id = @project_id
End
print @table_name
if (@table_name ='State' and @pk_fld_id = 'State_Id' and @delete_tree_node = 1)
Begin
Begin Transaction
Begin
delete from mytable where id in(select id from table1 where rid in(select rid from
table2 where sid in(select sid from table3 where tid = @pk_value )))
End
if @@error <> 0
Begin
goto Error_Routine
End
-- I have multiple delete statements here
Commit Transaction
End
Return
Error_Routine:
Rollback Transaction
GO
delete_tree_node 'Class','Id',6177,20
when I run this procedure with above parameters it takes long time to run. I am checking the condition if the parameter is state then only go to deletes block. but here I am passing class it takes so long time to print the variable. if I commented out the deletions block, it executes in 0 seconds. Why it is taking so much time to execute when I don't pass State.
Any help would be appreciated