select into from 与 select into from opendatasource
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了select into from 与 select into from opendatasource相关的知识,希望对你有一定的参考价值。
一、
select * into ##new1 from opendatasource('sqloledb','data source=192.168.9.3;
USER ID=sa; PASSWORD=cvbncvbn').emax.dbo.tbusretail as a where a.charged='1'
and (a.chargedate between '2011-07-31'and '2011-08-21')
insert into tbusretail
select *
from ##new1 as a where a.masterid not in (select masterid from tbusretail)
二、
select * into ##new1 from emax.dbo.tbusretail as a where a.charged='1'
and (a.chargedate between '2011-07-31'and '2011-08-21')
insert into tbusretail
select *
from ##new1 as a where a.masterid not in (select masterid from tbusretail)
对同样库表操作,一会出错,二没有问题,
一 查询分析
(所影响的行数为 2504 行)
服务器: 消息 245,级别 16,状态 1,行 5
将 varchar 值 'KX1110730CC010000001' 转换为数据类型为 smallint 的列时发生语法错误。
二 查询分析
(所影响的行数为 2504 行)
将 varchar 值 'KX1110730CC010000001'
插入的字段类型 smallint
这不支持隐性转换 参考技术A AD HOC好像是一个Ad Hoc网络,
英文不好呵,好像是注册AD HOC网络所在的地区什么的。
解决方法:
启用Ad Hoc Distributed Queries:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完成后,关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
因此我猜测是要你注册自己在该网络上。
Select into 与 Insert into … select … from
select 列名列表 into 新表名 from 原表名
(新表名:如果以“#”号开头的表名是临时表,没有则是永久表。)
Insert into Table2(field1,field2,…) select value1,value2,… from Table1
要求目标表Table2必须存在,field1,field2,…与value1,value2,…类型必须一一对应
以上是关于select into from 与 select into from opendatasource的主要内容,如果未能解决你的问题,请参考以下文章
Select into 与 Insert into … select … from
SQLINSERT INTO SELECT语句与SELECT INTO FROM语句
自动匹配 INSERT INTO ... SELECT ... FROM 中的列
select into from 和 insert into select的使用
select into from和insert into select from两种表复制语句区别
MySQL LAST_INSERT_ID() 与 INSERT INTO tablea SELECT FROM tableb