exec sp_addlinkedserver 'DD', '', 'SQLOLEDB','192.168.11.234'
exec sp_addlinkedsrvlogin 'DD','false',null,'sa','hello'
Go
CREATE TRIGGER DepInsertForSync
ON Department
FOR INSERT
AS
SET NOCOUNT ON
SET XACT_ABORT ON
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(--错误在此
'HIS_CSYSDEPTId',
'DEPT_NO',
'DEPT_CNAME',
'DEPT_ENAME'
)
SELECT
Dep.DepartmentId,
Dep.Code,
Dep.Name
FROM Department Dep
INNER JOIN Inserted vir ON vir.DepartmentId = Dep.DepartmentId
错误信息:
为不是函数的对象 'DD.sync.dbo.HIS_CSYSDEPT' 提供了参数。如果这些参数要作为表提示,则需要使用 WITH 关键字。
怎么解决?没用过with呢?
8 个解决方案
#1
exec sp_addlinkedserver 'DD', '', 'SQLOLEDB','192.168.11.234'
exec sp_addlinkedsrvlogin 'DD','false',null,'sa','hello'
Go
CREATE TRIGGER DepInsertForSync
ON Department
FOR INSERT
AS
SET NOCOUNT ON
SET XACT_ABORT ON
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT
values(
'HIS_CSYSDEPTId',
'DEPT_NO',
'DEPT_CNAME',
'DEPT_ENAME'
)
SELECT
Dep.DepartmentId,
Dep.Code,
Dep.Name
FROM Department Dep
INNER JOIN Inserted vir ON vir.DepartmentId = Dep.DepartmentId
#2
不对吧,你写的意思不就是将
values(
'HIS_CSYSDEPTId',
'DEPT_NO',
'DEPT_CNAME',
'DEPT_ENAME')
作为值写入了吗?我要的是后面的select中的值
#3
exec sp_addlinkedserver 'DD', '', 'SQLOLEDB','192.168.11.234'
exec sp_addlinkedsrvlogin 'DD','false',null,'sa','hello'
Go
CREATE TRIGGER DepInsertForSync
ON Department
FOR INSERT
AS
SET NOCOUNT ON
SET XACT_ABORT ON
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(
DEPT_NO,
DEPT_CNAME,
DEPT_ENAME
)
SELECT
Dep.DepartmentId,
Dep.Code,
Dep.Name
FROM Department Dep
INNER JOIN Inserted vir ON vir.DepartmentId = Dep.DepartmentId
#4
我不知道你的表结构,所以你要自己测试了,你insert那里是4列,select 才3列,肯定报错的。
#5
把列名的单引号去掉呢
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(
HIS_CSYSDEPTId,
DEPT_NO,
DEPT_CNAME,
DEPT_ENAME
)
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(
HIS_CSYSDEPTId,
DEPT_NO,
DEPT_CNAME,
DEPT_ENAME
)
#6
是啊,晕了
#7
去了引号还要去掉一列,不然一样报错
#8
1。列名上单引号去掉,不然就成字符串了
2。要插入的列数量要与插入值的列数量相同
2。要插入的列数量要与插入值的列数量相同
#1
exec sp_addlinkedserver 'DD', '', 'SQLOLEDB','192.168.11.234'
exec sp_addlinkedsrvlogin 'DD','false',null,'sa','hello'
Go
CREATE TRIGGER DepInsertForSync
ON Department
FOR INSERT
AS
SET NOCOUNT ON
SET XACT_ABORT ON
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT
values(
'HIS_CSYSDEPTId',
'DEPT_NO',
'DEPT_CNAME',
'DEPT_ENAME'
)
SELECT
Dep.DepartmentId,
Dep.Code,
Dep.Name
FROM Department Dep
INNER JOIN Inserted vir ON vir.DepartmentId = Dep.DepartmentId
#2
不对吧,你写的意思不就是将
values(
'HIS_CSYSDEPTId',
'DEPT_NO',
'DEPT_CNAME',
'DEPT_ENAME')
作为值写入了吗?我要的是后面的select中的值
#3
exec sp_addlinkedserver 'DD', '', 'SQLOLEDB','192.168.11.234'
exec sp_addlinkedsrvlogin 'DD','false',null,'sa','hello'
Go
CREATE TRIGGER DepInsertForSync
ON Department
FOR INSERT
AS
SET NOCOUNT ON
SET XACT_ABORT ON
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(
DEPT_NO,
DEPT_CNAME,
DEPT_ENAME
)
SELECT
Dep.DepartmentId,
Dep.Code,
Dep.Name
FROM Department Dep
INNER JOIN Inserted vir ON vir.DepartmentId = Dep.DepartmentId
#4
我不知道你的表结构,所以你要自己测试了,你insert那里是4列,select 才3列,肯定报错的。
#5
把列名的单引号去掉呢
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(
HIS_CSYSDEPTId,
DEPT_NO,
DEPT_CNAME,
DEPT_ENAME
)
INSERT INTO DD.sync.dbo.HIS_CSYSDEPT(
HIS_CSYSDEPTId,
DEPT_NO,
DEPT_CNAME,
DEPT_ENAME
)
#6
是啊,晕了
#7
去了引号还要去掉一列,不然一样报错
#8
1。列名上单引号去掉,不然就成字符串了
2。要插入的列数量要与插入值的列数量相同
2。要插入的列数量要与插入值的列数量相同