copyallwaterdata
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[copyallwaterdata]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[copyallwaterdata]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE proc copyallwaterdata
as
DECLARE @SQLString VARCHAR(3000)
DECLARE @TABLENAME VARCHAR(80)
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[needsynctablelist]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
begin
CREATE TABLE [dbo].[needsynctablelist] (
[tablename] [varchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[sync] [bit] NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[needsynctablelist] ADD
CONSTRAINT [DF_needsynctablelist_sync] DEFAULT (1) FOR [sync],
CONSTRAINT [PK_needsynctablelist] PRIMARY KEY CLUSTERED
(
[tablename]
) ON [PRIMARY]
end
insert into needsynctablelist
select *,1 from openquery(water,'select name from dbo.sysobjects where OBJECTPROPERTY(id, ''IsUserTable'') = 1 and name !=''needsynctablelist''' )
where not exists(select 1 from needsynctablelist where name=tablename)
DECLARE water_Cursor CURSOR FOR
select tablename from needsynctablelist where sync=1
OPEN water_Cursor
FETCH NEXT FROM water_Cursor into @TABLENAME
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQLString =N' if exists (select 1 from dbo.sysobjects where name='''+@TABLENAME+''') drop table '+@TABLENAME+' select * into '+@TABLENAME+' from openquery(water,''select * from dbo.'+@TABLENAME+''')'
exec (@SQLString)
FETCH NEXT FROM water_Cursor into @TABLENAME
END
CLOSE water_Cursor
DEALLOCATE water_Cursor
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[queryBasecodes]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[queryBasecodes]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE proc queryBasecodes
AS
begin
select * from dbo.COLLDT
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
copyallwaterdata的更多相关文章
随机推荐
- magento 图片缓存是如何生成的
Varien_Image_Adapter_Gd2 类 ,里面有个save()方法,通过图片格式拼出来的方法 call_user_func_array($this->_getCallback(' ...
- html5向左滑动删除特效
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- scrollba美化
1.overflow内容溢出时的设置(设定被设定对象是否显示滚动条) overflow-x水平方向内容溢出时的设置 overflow-y垂直方向内容溢出时的设置 以上三个属性设置的值 ...
- 解决 SVN cleanup 任务中断导致无法 update
解决 SVN cleanup 任务中断导致无法 update 今天在更新 svn 时, TortoiseSVN 一直在提示要进行 cleanup ,而执行 cleanup 时又提示: Cleanup ...
- QString 和 TCHAR 的相互转换
参考资料: http://www.cnblogs.com/fuyanwen/p/3200536.htmlhttp://www.cnblogs.com/wendao/archive/2012/07/27 ...
- 使用dbms_system追踪其它session
dbms_system是内部包,建议在官方指导下使用该包. SQL> desc dbms_system PROCEDURE ADD_PARAMETER_VALUE Argument Name T ...
- php:mysqli扩展
mysqli功能概述:http://php.net/manual/zh/mysqli.summary.php 代码(基本的用法):貌似可以防止sql注入 $root = "root" ...
- iOS6:在你的App内使用Passbook
前言 这是一篇翻译,感谢Jonathan Tang. 原文地址:iOS 6 Tutorial: Integrating Passbook into Your Applications 另外,看到另一篇 ...
- java提高篇(九)-----详解匿名内部类
在java提高篇-----详解内部类中对匿名内部类做了一个简单的介绍,但是内部类还存在很多其他细节问题,所以就衍生出这篇博客.在这篇博客中你可以了解到匿名内部类的使用.匿名内部类要注意的事项.如何初始 ...
- Swift语言实战晋级-第9章 游戏实战-跑酷熊猫-1
学习目标 一.进一步学习Swift的游戏制作 二.掌握SKNode,SKSpriteNode的运用 三.了解SpriteKit的物理系统 四.掌握动作(SKAction)的运用 在这一章,我们要通过制 ...