• [SQL]复制数据库某一个表到另一个数据库中


    摘自:http://www.cnblogs.com/beeone/p/5131479.html

    SQL:复制数据库某一个表到另一个数据库中
     
    SELECT * INTO 表1 FROM 表2 --复制表2如果只复制结构而不复制内容或只复制某一列只要加WHERE条件就好了
    例子:SELECT * INTO [IMCDB].[dbo].[SysLog] FROM [AimManageDB].[dbo].[SysLog]
    
    (将数据库AimManageDB中的SysLog表复制到数据库IMCDB中)
    
     select * into ren.dbo.person from person 
    将当前数据库中person表复制到数据库ren中,数据库ren中的表名为person
    (在数据库ren中,不刻意预先建立person表,软件会自动建成,同时,ren中的表明person可以随意改)
    跨服务器复制表
    select * INTO [SMSDB].[dbo].[SysLog] FROM openrowset('sqloledb',‘目标服务器’;'账号';'密码',[SMSDB].[dbo].[SysLog]) (将数据库目标服务器中的SysLog表复制本地的数据库SMSDB中) eg:如果出现以下错误: (SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。 系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。) 解决方法: 启用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 2012-8-26 其他导入方法 select * from table1 into table2 table2必须不存在 insert into table2 select * from table1 table2必须存在
  • 相关阅读:
    JS常见错误和分析
    angularjs 笔记(1) -- 引导
    各大浏览器hack
    AngularJS 配置和运行phonecat错误
    npm start 作用
    $.prop()和$.attr() 区别用法
    HDU 1251 统计难题 (Tire树)
    Luogu P3370 【模板】字符串哈希
    Luogu P3385 【模板】负环
    LuoguP1563 玩具谜题
  • 原文地址:https://www.cnblogs.com/wwz-wwz/p/6133404.html
Copyright © 2020-2023  润新知