SQL存储过程测试(4)——创建T
问题
如何创建一个T-SQL测试套件用于测试SQL存储过程。
设计
首无,通过插入大量测试平台数据准备好一个包含待测存储过程的底层数据库。接下来,使用一个SQL游标(cursor)遍历这个测试用例数据表。针对每个测试用例,调用待测存储过程并且取得它的返回值,把实际返回值与期望值进行比较,从而判定测试结果是通过与否,然后显示或保存测试结果。
方案
——testAuto.sql
——为dbEmployees填充数据
truncate table dbEmployees.dbo.tblEmployees
insert into dbEmployees.dbo.tblEmployees values('e11','Adams','15/10/2009')
insert into dbEmployees.dbo.tblEmployees values('e22','Baker','15/10/2009')
insert into dbEmployees.dbo.tblEmployees values('e33','Young','15/10/2009')
insert into dbEmployees.dbo.tblEmployees values('e44','Zetta','15/10/2009')
——此处插入更多数据
declare tCursor cursor fast_forward
for select caseID,input,expected
from dbTestCasesAndResults.dbo.tblTestCases
order by caseID
declare @caseID char(4),@input char(3),@expected int
declare @actual int,@whenRun datetime
declare @resultLine varchar(50)
set @whenRun = getdate()
open tCursor
fetch next
from tCursor
into @caseID,@input,@expected
while @@fetch_status = 0
begin
exec @actual = dbEmployees.dbo.usp_StatusCode @input
if (@actual = @expected)
begin
set @resultLine = @caseID + ': Pass'
print @resultLine
end
else
begin
set @resultLine = @caseID + ': FAIL'
&nbs
相关文档:
SQL触发器实例1
定义: 何为触发器?在SQL Server里面也就是对某一个表的一定的操作,触发某种条件,从而执行的一段程序。触发器是一个特殊的存储过程。
常见的触发器有三种:分别应用于Insert , Update , Delete 事件。
我为什么要使用触发器?比如, ......
今天要同步远程数据库时出错,报错“实际的服务器名称。。。。”,以下是解决方法
SQL code--查看当前服务名称
select @@servername
--如果与当前计算机名不一致,则用以下语句修改SQL Server服务器名
sp_dropserver 'old_name' --先删除原名称
GO
sp_addserver 'new_name', lo ......
import java.sql.*;
/*
* JAVA连接ACCESS,SQL Server,MySQL,Oracle数据库
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====连接ACCESS数据库 ......
SQL Server企业版/标准版/个人版的区别
http://blog.163.com/meteor_zc/blog/static/33150220200811291738603/
SQL Server企业版/标准版/个人版的区别?--西部E网weste.net 2008-12-29 01:07
分类:默认分类 字号: 大大 中中 小小 SQL Server企业版/标准版/个人版的区别?
对于新接触SQL数据库 ......
简介
本文讲述MS SQL Server和Oracle对数据库事务处理的差异性,以及Oracle如何对事务处理的实现。
什么是事务
数据库事务(Database Transaction)是一组数据库操作的处理单元。事务符合ACID的特性:
Atomic:原子性,要么全部要么一无所有。All or None.
Consisten ......