1) DECLARE @tbname sysname,@sql varchar(100)
SET @sql='SELECT '+@tbname+'=name FROM sysobjects where id=1'
EXEC(@sql)
SELECT @tbname
2) declare @num int, @sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName '
exec sp_executesql @sqls,N'@a int output',@num output
3)
Set @StrSQL = ''
Set @StrSQL = '
set @a=''''
Select @a=@a + Cast(' + @IDField + ' As varchar(20)) +'','''+ '
From
'+ @TableName +'
Where
ParentID = ' + Cast(@NodeID As varchar(20))
--print @StrSQL
Exec sp_executeSQL @StrSQL, N'@a varchar(4000) output',@cNodeIDStr out
--print @cNodeIDStr