SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ntm_test_indent_node]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[ntm_test_indent_node] GO -- converts from node_name to node_id. CREATE PROCEDURE ntm_test_indent_node @node_table_name varchar(255) = 'ntm_nodes' ,@TreeID uniqueidentifier ,@node_name varchar(255) ,@str_debug varchar(255) = "NODEBUG" as declare @sql_str nvarchar(1000) DECLARE @IndentID uniqueidentifier begin set @sql_str = N'select @IndentID = InternalNodeID from ' + @node_table_name + ' where TreeID = ''' + convert(nvarchar(50), @TreeID) + ''' and NodeName = ''' + @node_name + '''' execute sp_executesql @sql_str, N'@IndentID uniqueidentifier out', @IndentID out exec ntm_indent_node @node_table_name=@node_table_name, @TreeID=@TreeID, @IndentID=@IndentID, @str_debug=@str_debug /* return the success status code */ return(1) end GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO