通过作业定时同步两个数据库
定时同步服务器上的数据的例子:--测试环境,SQL Server2000,远程服务器名:xz,用户名为:sa,无密码,测试数据库:test--1. 链接服务器上的表create table [user](id int primary key,number varchar(4),name varchar(10))go--2. 本地服务器上的表--本机的表,state说明:null 表示新增记录,1 表示修改过的记录,0 表示无变化的记录if exists (select * from dbo.sysobjects where id = object_id(N'[user]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [user]GOcreate table [user](id int identity(1,1),number varchar(4),name var
存储过程中返回结果以及两种错误类型
存储过程中返回结果 从存储过程中返回结果有三种方式: 1、 返回结果集 2、 设置OUTPUT参数的值 3、 通过RETURN参数返回状态 在存储过程中的错误有两种类型: 1、 数据库相关的错误 2、 业务逻辑错误[@more@] 1、 返回结果集 这是客户端应用程序返回结果的最通用的方法。结果集是通过使用SELECT语句选择数据产生的。结果集可以从永久表、临时表或局部变量中产生。将结果返回到另一个存储过程不是一种有效的方法。存储过程不能访问另一个存储过程建立的结果集。 例如从永久表中返回结果集: USE pubs GO CREATE PRO
关于日志
清空日志[@more@]解决方法 日志文件满而造成SQL数据库无法写入文件时,可用两种方法: 一种方法:清空日志。 1.打开查询分析器,输入 DUMP TRANSACTION 数据库名 WITH NO_LOG 2.再打开企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就可以了。 另一种方法有一定的风险性,因为SQL SERVER的日志文件不是即时写入数据库主文件的,如处理不当,会造成数据的损失。 1: 删除LOG: 分
SQL Server - Date and Time Functions
In the previous articles in this series, I introduced you to aggregate and system-related functions. This article continues to explore various types of built-in functions. I will walk you through the most useful functions that fall into date and time, math, and text function categories. Date and time functions enable a programmer to get the system date, as well as to manipulate the date and time values stored in the database. Because date and time functions are useful in many differen
SQL Server - String Functions
bString Functions: Incrementing a Number in a Char Derrick writes "I have a value : 'PIT000' I need to increment this value i.e. PIT001, PIT002, etc until PIT999. How do I do this using a SQL query. The next step is: once you reach PIT999, the value needs to change to PIU000!!" We certainly can do this in SQL Server and it gives us a chance to talk about some neat string functions too. I probably shouldn't even ask this question . . . but "Which Pointy
ADO.NET 跟踪数据访问
简介 自 ODBC Trace 发布以来,我一直在期待面向数据访问的良好的通用内置跟踪工具。OLE DB 有许多不同类型的跟踪方式;我想到的两个是与 Visual Studio 分析器兼容的工具和 ATLTRACE(用于 ATL OLE DB 模板的跟踪宏)。OLE DB 和 MDAC 的问题不在于它们没有跟踪,而在于有太多不同种类的跟踪,每个跟踪都绑定到不同的评估机制。很难(如果不是不可能的话)跟踪到各层的数据访问堆栈并获得一 个跟踪输出。 ADO.NET 2.0 和 SQL 本机客户端(一个新的 OLE DB/ODBC/网络库功能)包含一个灵活而丰富的内置数据跟踪工具。Microsoft 已经
ASP与存储过程(Stored Procedures)
ASP与存储过程(Stored Procedures)的文章不少,但是我怀疑作者们是否真正实践过。我在初学时查阅过大量相关资料,发现其中提供的很多方法实际操作起来并不是那么回 事。对于简单的应用,这些资料也许是有帮助的,但仅限于此,因为它们根本就是千篇一律,互相抄袭,稍微复杂点的应用,就全都语焉不详了。 现在,我基本上通过调用存储过程访问SQL Server,以下的文字虽不敢保证绝对正确,但都是实践的总结,希望对大家能有帮助。 存储过程就是作为可执行对象存放在数据库中的一个或多个SQL命令。 定义总是很抽象。存储过程其
ASP 编程中20个非常有用的例子
ASP 编程中20个非常有用的例子[@more@]1.如何用Asp判断你的网站的虚拟物理路径 答:使用Mappath方法 < p align="center" >< font size="4" face="Arial" >< b > The Physical path to this virtual website is: < /b >< /font > < font color="#FF0000" size="6" face="Arial" > < %= Server.MapPath("")% > < /font >< /p > 2.我如何知道使用者所用的浏览器? 答:使用the Request obj
ADO的连接
ADO的连线主要可分成透过OLE DB Privder的方式与OLE DB Provider for ODBC,前者很明显的是Microsoft公司极力发展的方式,据说它比透过ODBC的方式快且所 资源少 ,但实№上如何,几年之後就可很清楚了。不过目前有Privder提供OLE DB介面者尚没有非常多,但提供ODBC介面者就很多了,在只有ODBC Driver之下,如果也要使用ADO的话那可以使用OLE DB Provider for ODBC的介面,然而它的Performance和使用RDO来比,那得花上好些工夫试看看,至少我没有那些工夫做这种事。 great reference http://doc.51windows.net/ado/?url=/ado/dasdka
MySQL 5.0 新特性
Introduction 简介 MySQL 5.0 新特性教程是为需要了解5.0版本新特性的MySQL老用户而写的。简单的来说是介绍了“存储过程、触发器、视图、信息架构视图”,我打算每天一部分,来 连载这个教程.如果你想看一次看完PDF版本的教程,请到down.phpv.net下载.在此感谢译者陈朋奕的努力. 希望这本书能像内行专家那样与您进行对话,用简单的问题、例子让你学到需要的知识。为了达到这样的目的,我会从每一个细节开始慢慢的为大家建立概念,最后会给大家展示较大的实用例,在学习之前也许大家会认为这个用例很难,但是只要跟着课程去学,相信很快就
If SQL 2005 is slower than 2000 (gethering.....)
try running profiler for some time during these operations. help identifying the bottleneck(check for locks)...also check the transaction isolation levels u had earlier and now.... Have you rebuild your indexes and updated your statistics? SQL 2005 might choose a poor plan if you fail to do so since the engine has changed between 2000 and 2005 [@more@]
ASP sending Email
SET rsMailQ = objConn.Execute("SELECT * FROM mailqueue WHERE date_sent IS NULL") While NOT rsEmails.EOF Set objMailer = Server.CreateObject("Persits.MailSender") objMailer.Host = MailServer objMailer.Charset = "UTF-8" objMailer.ContentTransferEncoding = "Quoted-Printable" objMailer.From = rsEmails("From") objMailer.FromName = rsEmails("FromName") objMailer.AddAddress rsEmails("To") objMailer
Disaster Plan
Check database and log file of (Master, HowdyDatabase, Btell, BlackPebble, OCE), to use sp_attach_db. - sp_attach_single_file_db, to find out the last checkpoint. If cann’t, go to next step[@more@] If there is no .ldf, create a same name database, then stop sql server, use the .mdf file to cover the name database file, then rebuild log file, set emergency mode (sysdatabases status = 32768), but need to remember the original sysdatabases status va
Oracle和MS SQL server的函数对比
Oracle和MS SQL server的函数对比[@more@]---------数学函数 1.绝对值 S:select abs(-1) value O:select abs(-1) value from dual 2.取整(大) S:select ceiling(-1.001) value O:select ceil(-1.001) value from dual 3.取整(小) S:select floor(-1.001) value O:select floor(-1.001) value from dual 4.取整(截取) S:select cast(-1.002 as int) value O:select trunc(-1.002) value from dual 5.四舍五入 S:select round(1.23456,4
SQL SERVER2005分区表创建SQL
Saw this function from other book, here is an example, save it in case[@more@] --创建分区表之前,请在新建数据前添加数据库文件和文件组(文件组数>=分区数)--创建分区函数(有三个范围会产生四个分区)CREATE PARTITION FUNCTION FiveYearDateRangePFN(datetime)ASRANGE LEFT FOR VALUES ('20061031 23:59:59.997','20061130 23:59:59.997','20061231 23:59:59.997')--删除PARTITION FUNCTION--DROP PARTITION FUNCTION FiveYearDateRangePFN--分区映射到文件组的方案('200610'代表文件组,文件组的个数不得少于分区的个数,文件组