我来自这里的例子[a link],它解释了如何编写递归查询。 WITH security_menu_Recursive(Parent,MenuId,MenuName,LEVEL)
AS
(
SELECT vparent,vmenuid,vmenuname,0 AS LEVEL FROM dbo.SecurityMenu WHERE vParent = null
UNION A
我需要检索孩子父母的最后(或第一)ID。 实施例: ID PARENT_ID
----------------
1 NULL
2 1
3 2
所以,如果我搜索ID = 3的父ID我将具有1作为结果。 我试过,但它给了我同样的ID ... with
tree(id)
as
(
select id
from myTable
where id
我不知道该怎么解释这一点,我想下面的方法来工作,但它给了我错误说 的as' operator cannot be used with a non-reference type parameter T”。考虑添加`class'或引用类型约束。 任何人都可以帮我解决这个问题吗? public T GetRoot<T>() {
if (this is T)
return this
所以我试图创建我的第一个递归udf(使用MS SQL)去除字符串中不是字母和数字的任何东西。 这是由这个帖子的启发(Replace with wildcard, in SQL) CREATE FUNCTION uf_RemoveNonAlphaNumericChar(
@p_CharIndex int,
@p_Value Varchar(max))
RE