Speed Up SQL Server Apps -提高SQL Server应用程序的运行效率
Learn 10 useful tips and tricks that help boost SQL Server application performance—and streamline development and deployment as well. 学习10个有用的技巧来提高SQL Server应用程序的运行效率,简化开发和部署。-by Roman Rehak, 本文属于转载,谢谢原作者Roman Rehak. Developers love database programming tips, tricks, and workarounds—especially those that slash development time or boost application performance. Here's a collection of such nuggets for developing SQL Server applications.[@mor
Designing High Performance Stored Procedures
anaging large amounts of data is always a challenge. Several major database vendors claim that their database engines are ready for terabytes of data, which is true to a certain extent. However, when those terabytes are not static data, but live information that people update constantly, search on, report from, and run web applications against, and when the number of concurrent users accessing the data peaks significantly as well, providing fast, unblocked access to those terabytes beco
什么是存储过程?
存储过程的种类: 1.系统存储过程:以sp_开头,用来进行系统的各项设定.取得信息.相关管理工作, 如 sp_help就是取得指定对象的相关信息 2.扩展存储过程 以XP_开头,用来调用操作系统提供的功能 exec master..xp_cmdshell 'ping 10.8.16.1' 3.用户自定义的存储过程,这是我们所指的存储过程 [@more@]常用格式 Create procedure procedue_name [@parameter data_type][output] [with]{recompile|encryption} as sql_statement 解释: output:表示此参数是可传回的 with {recompile|encryption} recomp
DBCC
在危急时刻,数据库一致性检测(DBCC)可能是你最重要的工具。本文向你简单介绍DBCC的功能,它们包括: 检测表和相关目录的完整性。 检测整个数据库。 检测数据库页的完整性。 重建任何指定表中的目录。 你为何需要学习DBCC 如果你甚至还不知道为何使用DBCC,下面提供一些原因: 需要不断分割数据库页(表和目录),这可能会破坏分配。 目录可能遭到破坏,或效率降低。 SQL Server引擎有时会误解你的意图。 需要大量更新时,事情可能会很麻烦(记住,任何指定的更新实际为删除和插入)。 单个页面,虽然仍然“
用SQL Server处理数据层错误
与数据库进行交互操作的时候会发生很多错误,但是很多开发人员都不知道如何处理数据库层的错误。本文我们探讨如何利用SQL Server和T-SQL来处理数据库代码里的错误。[@more@]开发人员在努力做到妥善地处理意外,这样用户 就不用担心天书般的系统错误信息。出于这个原因,异常处理是每个.NET应用程序的一个标准部分。Try/catch块让你能够捕捉异常并从该点控制应用 程序的执行。与数据库进行交互操作的时候会发生很多错误,但是很多开发人员都不知道如何处理数据库层的错误。本文我们将探讨如何利用SQLServer和 T-SQL来处理你数据库代码里
用存储过程或触发器+作业调度进行数据库同步
/*--同步两个数据库的示例 引用(邹建) 测试环境及同步要求: 有数据库服务器srv1和srv2,两台电脑能互相访问,有数据srv1.库名..author有字段:id,name,phone,srv2.库名..author有字段:id,name,telphone,adress 要求:srv1.库名..author增加记录则srv1.库名..author记录增加srv1.库名..author的phone字段更新,则srv1.库名..author对应字段telphone更新--*/ [@more@]--大致的处理步骤--1.在 srv1 上创建连接服务器,以便在 srv1 中操作 srv2,实现同步exec sp_addlinkedserver 'srv2','','SQLOLEDB','srv2的sql实例名或ip'exec sp_addlink
存储过程中返回结果以及两种错误类型
存储过程中返回结果 从存储过程中返回结果有三种方式: 1、 返回结果集 2、 设置OUTPUT参数的值 3、 通过RETURN参数返回状态 在存储过程中的错误有两种类型: 1、 数据库相关的错误 2、 业务逻辑错误[@more@] 1、 返回结果集 这是客户端应用程序返回结果的最通用的方法。结果集是通过使用SELECT语句选择数据产生的。结果集可以从永久表、临时表或局部变量中产生。将结果返回到另一个存储过程不是一种有效的方法。存储过程不能访问另一个存储过程建立的结果集。 例如从永久表中返回结果集: USE pubs GO CREATE PRO
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