您好我已经使用多个表连接创建了这个SQL视图(即 Login_Monitor )
我现在想要做的是在此视图中使用几列来写入我创建的单独表格。
但是我写了很多 Null 值写入表而不是实际数据。
这就是我创建目标表的方式
create table MS_Login_Monitor
(date date,
time time,
USERID char(15),
COMPANY_NAME char(65),
LOGIN_DATE_TIME datetime,
TIME_SINCE_LAST_ACTION int,
)
这是我用来将视图数据写入目标表
的查询declare @date date
declare @time time
declare @USERID char(20)
declare @COMPANY_NAME char(65)
declare @LOGIN_DATE_TIME datetime
declare @TIME_SINCE_LAST_ACTION nchar(7)
set @date = CURRENT_TIMESTAMP
set @time = CURRENT_TIMESTAMP
select * from Login_Monitor
INSERT INTO DYNAMICS..MS_Login_Monitor (date, time,USERID, COMPANY_NAME, LOGIN_DATE_TIME, TIME_SINCE_LAST_ACTION)
VALUES (@date, @time,@USERID,@COMPANY_NAME, @LOGIN_DATE_TIME, @TIME_SINCE_LAST_ACTION)
有人可以解释一下,为什么我得到写入表的NULL值,或者我的SQL查询中是否有错误。
由于
答案 0 :(得分:0)
你可以尝试这样的事情;
INSERT INTO DYNAMICS..MS_Login_Monitor (date, time,USERID, COMPANY_NAME, LOGIN_DATE_TIME, TIME_SINCE_LAST_ACTION)
select @date, @time, X, Y.....(use actual column names of view) from Login_Monitor
你不需要其他参数。