got*_*tqn 5 t-sql loops function updates
我有下表:
RecordID
Name
Col1
Col2
....
ColN
Run Code Online (Sandbox Code Playgroud)
该RecordIDIS BIGINT PRIMARY KEY CLUSTERED IDENTITY(1,1)和RecordID与Name被初始化.其他列是NULL.
我有一个函数,它返回有关其他列的信息Name.
要初始化我的表,我使用以下算法:
Name值有没有办法在没有循环的情况下做到这一点?
交叉申请基本上是为此而建的
SELECT D.deptid, D.deptname, D.deptmgrid
,ST.empid, ST.empname, ST.mgrid
FROM Departments AS D
CROSS APPLY fn_getsubtree(D.deptmgrid) AS ST;
Run Code Online (Sandbox Code Playgroud)
UPDATE some_table
SET some_row = another_row,
some_row2 = another_row/2
FROM some_table st
CROSS APPLY
(SELECT TOP 1 another_row FROM another_table at WHERE at.shared_id=st.shared_id)
WHERE ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21170 次 |
| 最近记录: |