sql - 使用派生列插入 EXEC xp_dirtree
问题描述
我正在尝试使用 xp_dirtree 存储过程在 SSRS 报告中创建完整的文件路径:
CREATE TABLE #tt1 (
id int IDENTITY(1,1)
,subdirectory nvarchar(512)
,depth int
,isfile bit);
INSERT #tt1
EXEC xp_dirtree @dir, 10, 1
但是,作为补充,我想在存储过程顶部的插入中添加一列。所以像
CREATE TABLE #tt1 (
id int IDENTITY(1,1)
,subdirectory nvarchar(512)
,depth int
,isfile bit
,NewColumn nvarchar(100)
);
INSERT #tt1
EXEC xp_dirtree @dir, 10, 1, 'NEW COLUMN'
然而,这不起作用并踢出去
Msg 213, Level 16, State 7, Procedure xp_dirtree, Line 1 [Batch Start Line 0]
Column name or number of supplied values does not match table definition.
解决方案
您需要在使用insert into . .
语句时修复列:
INSERT INTO #tt1 (subdirectory, depth, isfile, NewColumn)
EXEC xp_dirtree @dir, 10, 1, 'NEW COLUMN'
推荐阅读
- sql - MSSQL WHERE YEAR 子句返回所有日期而不是指定日期
- asp.net - 通过vb.net中的foreach循环在列表中插入类属性
- python - 用整数规划求解最小化
- sql - hibernate如何登录哪部分代码导致了给定的SQL
- javascript - 反应用户引用不向字段添加焦点状态
- json - 数据帧到 JSON 的转换
- gitlab-ci - 如何在 GitLab 管道中运行安全代码扫描?
- c++ - 如何使用模板类在 C++ 中正确进行多重继承?
- c# - ASP.NET Core web.config 位置使用
- vue.js - 通过 axios 发出 Post 请求时将 HttpListenerContext.User 设为 null