易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL存储过程测试(9)——示例程序

      此部分内容创建一个轻量级T-SQL测试套件,总共有3个脚本:
用于创建测试平台数据和待测存储过程的脚本
--======================
--makeDbTestAndResults.sql
use master
go
if exists (select * from sysdatabases where name = 'DbTestAndResults')
 drop database makeDbTestAndResults
go
if exists (select * from sysxlogins where name = 'testLogin')
 exec sp_droplogin 'testLogin'
go
create database makeDbTestAndResults
go
use makeDbTestAndResults
go
create table tb1TestCases
(
 caseID char(4) primary key,
 input datetime not null,
 expectedChecksum int not null
)
go
--下面插入的是用于usp_HiredAfter的测试数据,采用了对期望值求校验和的方法
--也可以通过BCP,BTS或者C#程序从文本文件读入这些数据
insert into tb1TestCases values('0001','10/25/2009',1042032)
insert into tb1TestCases values('0002','10/25/2009',9999999)--deliberate error
insert into tb1TestCases values('0003','10/25/2008',25527856)
insert into tb1TestCases values('0004','10/10/2006',1042032)
go
create table tb1Results
(
 caseID char(4) not null,
 result char(4) not null,
 whenRun datetime not null
)
go
exec sp_addlogin 'testLogin','secret'
go
exec sp_grantdbaccess 'testLogin'
go
grant select,insert,delete,update on tb1TestCases to testLogin
go
grant select,insert,delete,update on tb1Results to testLogin
go
--结束脚本
用于创建测试例例数据和测试结果存储的脚本
--==========================
--makeDbEmployees.sql
use master
go
if exists(select * from sysdatabases where name = 'dbEmployees')
 drop database dbEmployees
go
if exists(select * from sysxlogins where name = 'employeesLogin')
 exec sp_droplogin 'employeesLogin'
go
create database dbEmployees
go
use dbEmployees
go
create table tb1Employees
(
 empID char(3) primary key,
 empLast varchar(35) not null,
 empDOH datetime not null,
)
go
insert into tb1Employees values('e11','Adams','10/25/2009')
insert into tb1Employees


相关文档:

JDBC连接SQL Server 2005的方法

一、下载安装
1、SQL Server 2005 Express Edition
下载 SQL Server 2005 Express Edition(下载页面):
http://msdn.microsoft.com/vstudio/express/sql/download/
安装完数据库后设置ICP/IP协议启动(这一步不能少,默认是TCP/IP不启用的),具体如下:
(1)打开SQL Server Configuration Manager
(2)转到SQL S ......

由将SQL查询结果转化为pojo的想到的

今天在网上上看见一篇“将SQL查询结果转化为pojo对象的”博客,博主自定义做了一个类如下:
import java.lang.reflect.Field;  
import java.util.List;  
 
import org.hibernate.HibernateException;  
import org.hibernate.property.ChainedPropertyAccessor;&n ......

sql小计汇总 rollup用法实例分析

 这里介绍sql server2005里面的一个使用实例:
CREATE TABLE tb(province nvarchar(10),city nvarchar(10),score int)
INSERT tb SELECT '陕西','西安',3
UNION ALL SELECT '陕西','安康',4
UNION ALL SELECT '陕西','汉中',2
UNION ALL SELECT '广东','广州',5
UNION ALL SELECT '广东','珠海',2
UNION ......

在ORACLE和sql server中简单备份table的方法

如果temp_t1不存在,
oracle:
create table temp_t1
as
select * from t1
sql server:
select * into temp_t1 from t1
如果temp_t1存在,
oracle:
insert into table temp_t1
select * from t1
sql server:
insert into table temp_t1
select * from t1 ......

SQL SERVER 2005 存储过程

USE AdventureWorks
GO
CREATE PROC spEmployee
AS
SELECT * from Humanresources.Employee
EXEC spEmployee
ALTER PROC spEmployee
AS SELECT EmployeeID from Humanresources.Employee
drop proc spEmployee
ALTER PROC spEmployee
@LastName nvarchar(50) = NULL
AS
IF @LastName IS NULL
SELECT * f ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号