原文:REDGATE SQL TEST的使用

REDGATE SQL TEST的使用

SQL TEST下载和破解可以参考这篇文章:http://www.cnblogs.com/VAllen/archive/2012/10/01/SQLTest.html#

SQL TEST默认已经创建好5个测试数据库中错误的存储过程

第一个存储过程测试数据库中是否有Decimal数据类型大小的问题

第二个存储过程测试数据库中是否有以SP_开头的存储过程

第三个存储过程测试数据库中使用的动态sql是否没有使用sp_executesql来调用

第四个存储过程测试数据库中的存储过程是否有@@Identity全局变量

第五个存储过程测试数据库中存储过程是否有使用SET ROWCOUNT

您可以编辑这些默认的测试存储过程

例如第一个存储过程,测试Decimal数据类型大小错误

 ALTER PROCEDURE [SQLCop].[test Decimal Size Problem]
AS
BEGIN
-- Written by George Mastros
-- February 25, 2012
-- http://sqlcop.lessthandot.com
-- http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/always-include-precision-and-scale-with SET NOCOUNT ON Declare @Output VarChar(max)
Set @Output = '' Select @Output = @Output + Schema_Name(schema_id) + '.' + name + Char(13) + Char(10)
From sys.objects
WHERE schema_id <> Schema_ID('SQLCop')
And schema_id <> Schema_Id('tSQLt')
and (
REPLACE(REPLACE(Object_Definition(object_id), ' ', ''), 'decimal]','decimal') COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI LIKE '%decimal[^(]%'
Or REPLACE(REPLACE(Object_Definition(object_id), ' ', ''), 'numeric]','numeric') COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI LIKE '%[^i][^s]numeric[^(]%'
)
Order By Schema_Name(schema_id), name If @Output > ''
Begin
Set @Output = Char(13) + Char(10)
+ 'For more information: '
+ 'http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/always-include-precision-and-scale-with'
+ Char(13) + Char(10)
+ Char(13) + Char(10)
+ @Output
EXEC tSQLt.Fail @Output
End
END;

您也可以运行他,他会检查数据库中每个表的数据类型,并检查每个表中的数据

如果你想一次过执行所有的测试存储过程可以按左上角的run tests按钮


下面来试一下怎麽使用,先创建一个以SP_开头的存储过程,您可以按左上角的run tests按钮或者只选中test Procedures Named SP_

这个测试存储过程,然后右键-》run test

其他4个测试存储过程

 ALTER PROCEDURE [SQLCop].[test Procedures With SET ROWCOUNT]
AS
BEGIN
-- Written by George Mastros
-- February 25, 2012
-- http://sqlcop.lessthandot.com
-- http://sqltips.wordpress.com/2007/08/19/set-rowcount-will-not-be-supported-in-future-version-of-sql-server/ SET NOCOUNT ON Declare @Output VarChar(max)
Set @Output = '' SELECT @Output = @Output + Schema_Name(schema_id) + '.' + name + Char(13) + Char(10)
From sys.all_objects
Where type = 'P'
AND name Not In('sp_helpdiagrams','sp_upgraddiagrams','sp_creatediagram','testProcedures With SET ROWCOUNT')
And Replace(Object_Definition(Object_id), ' ', '') COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI Like '%SETROWCOUNT%'
And is_ms_shipped = 0
and schema_id <> Schema_id('tSQLt')
and schema_id <> Schema_id('SQLCop')
ORDER BY Schema_Name(schema_id) + '.' + name If @Output > ''
Begin
Set @Output = Char(13) + Char(10)
+ 'For more information: '
+ 'http://sqltips.wordpress.com/2007/08/19/set-rowcount-will-not-be-supported-in-future-version-of-sql-server/'
+ Char(13) + Char(10)
+ Char(13) + Char(10)
+ @Output
EXEC tSQLt.Fail @Output
End
END;
 ALTER PROCEDURE [SQLCop].[test Procedures with @@Identity]
AS
BEGIN
-- Written by George Mastros
-- February 25, 2012
-- http://sqlcop.lessthandot.com
-- http://wiki.lessthandot.com/index.php/6_Different_Ways_To_Get_The_Current_Identity_Value SET NOCOUNT ON Declare @Output VarChar(max)
Set @Output = '' Select @Output = @Output + Schema_Name(schema_id) + '.' + name + Char(13) + Char(10)
From sys.all_objects
Where type = 'P'
AND name Not In('sp_helpdiagrams','sp_upgraddiagrams','sp_creatediagram','testProcedures with @@Identity')
And Object_Definition(object_id) COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI Like '%@@identity%'
And is_ms_shipped = 0
and schema_id <> Schema_id('tSQLt')
and schema_id <> Schema_id('SQLCop')
ORDER BY Schema_Name(schema_id), name If @Output > ''
Begin
Set @Output = Char(13) + Char(10)
+ 'For more information: '
+ 'http://wiki.lessthandot.com/index.php/6_Different_Ways_To_Get_The_Current_Identity_Value'
+ Char(13) + Char(10)
+ Char(13) + Char(10)
+ @Output
EXEC tSQLt.Fail @Output
End END;
 ALTER PROCEDURE [SQLCop].[test Procedures using dynamic SQL without sp_executesql]
AS
BEGIN
-- Written by George Mastros
-- February 25, 2012
-- http://sqlcop.lessthandot.com
-- http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/avoid-conversions-in-execution-plans-by- SET NOCOUNT ON Declare @Output VarChar(max)
Set @Output = '' SELECT @Output = @Output + SCHEMA_NAME(so.uid) + '.' + so.name + Char(13) + Char(10)
From sys.sql_modules sm
Inner Join sys.sysobjects so
On sm.object_id = so.id
And so.type = 'P'
Where so.uid <> Schema_Id('tSQLt')
And so.uid <> Schema_Id('SQLCop')
And Replace(sm.definition, ' ', '') COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI Like '%Exec(%'
And Replace(sm.definition, ' ', '') COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI Not Like '%sp_Executesql%'
And OBJECTPROPERTY(so.id, N'IsMSShipped') = 0
Order By SCHEMA_NAME(so.uid),so.name If @Output > ''
Begin
Set @Output = Char(13) + Char(10)
+ 'For more information: '
+ 'http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/avoid-conversions-in-execution-plans-by-'
+ Char(13) + Char(10)
+ Char(13) + Char(10)
+ @Output
EXEC tSQLt.Fail @Output
End END;
 ALTER PROCEDURE [SQLCop].[test Procedures Named SP_]
AS
BEGIN
-- Written by George Mastros
-- February 25, 2012
-- http://sqlcop.lessthandot.com
-- http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/don-t-start-your-procedures-with-sp_ SET NOCOUNT ON Declare @Output VarChar(max)
Set @Output = '' SELECT @Output = @Output + SPECIFIC_SCHEMA + '.' + SPECIFIC_NAME + Char(13) + Char(10)
From INFORMATION_SCHEMA.ROUTINES
Where SPECIFIC_NAME COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI LIKE 'sp[_]%'
And SPECIFIC_NAME COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI NOT LIKE '%diagram%'
AND ROUTINE_SCHEMA <> 'tSQLt'
Order By SPECIFIC_SCHEMA,SPECIFIC_NAME If @Output > ''
Begin
Set @Output = Char(13) + Char(10)
+ 'For more information: '
+ 'http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/don-t-start-your-procedures-with-sp_'
+ Char(13) + Char(10)
+ Char(13) + Char(10)
+ @Output
EXEC tSQLt.Fail @Output
End
END;

还会在测试数据库生成一些存储过程和函数

某些存储过程还加密了的


创建测试存储过程

SQL TEST跟SQL PROMPT一样,根据SQLSERVER版本来开发的

REDGATE SQL TEST的使用的更多相关文章

  1. [SQL]透過redgate SQL Monitor 來找出 ASYNC_NETWORK_IO 問題

    原文:[SQL]透過redgate SQL Monitor 來找出 ASYNC_NETWORK_IO 問題 最近因為在查一個SQL的效能問題,透過 sys.dm_os_wait_stats 來取得To ...

  2. 使用Red Gate Sql Compare 数据库同步工具进行SQL Server的两个数据库的结构比较、同步

    将测试版的项目同步(部署)到正式版的时候,两个数据库的结构比较与同步时,如果修改数据库的时候没有记录好修改了那些表,很难将两个数据库进行同步 RedGate Sql Compare使用简介说明: 1. ...

  3. 1. SQL Server服务器监控实现方法

    对于服务器的监控,和对数据库的监控,很少有合二为一的工具,如果有的话,一般是付费软件,或者自行开发的工具.所以如果不想购买软件,也不想花精力去开发的话,可以结合一些免费/开源的工具.自定义脚本,来完成 ...

  4. 10款最佳SQL Server服务器监控工具

    转自:http://server.51cto.com/sSecurity-587355.htm 推荐 | 10款最佳SQL Server服务器监控工具 服务器是网络中最重要的资源之一,SQL Serv ...

  5. 使用sql compare生成的sql语句

    创建表以及主键 判断表是否存在 OBJECT_ID 判断主键是否存在 SELECT 1 FROM sys.indexes WHERE name = N'PK_LISA_NoUseWebpartRepl ...

  6. SQL索引管理器 - 用于SQL Server和Azure上的索引维护的免费GUI工具

    我作为SQL Server DBA工作了8年多,管理和优化服务器的性能.在我的空闲时间,我想为宇宙和我的同事做一些有用的事情.这就是我们最终为SQL Server和Azure 提供免费索引维护工具的方 ...

  7. TFS代码签入指导

    1. 如果文件没有被放入到TFS中, 那么它是不存在的. 这一点是最好被理解的, 如果你的代码没有被签入到代码管理中,那么就不可能被团队的其他人获取的得到. 具体如何将文件纳入到TFS中请参考 Pla ...

  8. Visual Studio 2017十五项新功能体验

    Visual Studio 2017正式已经于2017.3.7号正式发布,选在这一天发布也是为了纪念Visual Studio 二十周年.MVP 2017技术峰会将于这个周末(3.17)在北京举办,由 ...

  9. Visual Studio 2017 Enterprise (15.3)

    版本15.3更新在用户离线下载时更加人性化,包含了进度显示,下载出错可以输入R,进行下载的重新尝试,并在当前下载框下继续下载为完成的作业,结合 --layout 参数的离线文件的检查和修复,并且在下载 ...

随机推荐

  1. Centos6.5下一个Ceph存储集群结构

    简单的介绍 Ceph的部署模式下主要包括下面几个类型的节点 • Ceph OSDs: A Ceph OSD 进程主要用来存储数据,处理数据的replication,恢复,填充.调整资源组合以及通过检查 ...

  2. WWDC2014开源

    A Cocoa OSX App to help you download WWDC2014 videos 地址:https://github.com/iosxtools/WWDC2014 版权声明:本 ...

  3. android 该项目的优化toast优化技巧

    我们这样做的时候经常登录认证使用toast提示用户输入出现错误等..很多人都直接使用 Toast.makeText(LoginActivity.this, "请联系小区的物业管理" ...

  4. SQL Server中tempdb的管理

    原文:SQL Server中tempdb的管理 资料来自: http://blogs.msdn.com/b/sqlserverstorageengine/archive/tags/tempdb/ ht ...

  5. HTML5 transform三维立方体(随着旋转的效果)

    为了得到更好的把握transform精华.因此,我们决定完成三维立方体模型,可以实现360无死三维旋转作用. 但旋转更难推断每侧视图的序列.然而,完美的解决方案,我希望有人能回答. 源代码直接贡献的朋 ...

  6. java假设去请求一个网页的数据

    我们能够通过在java程序中模拟浏览器一样,把数据抓下来,详细方法是在java程序中set header和cookie,以下是一个样例: public class NetConnection { pu ...

  7. 安卓模拟器错误: Could not open

    在进行android模拟器測试的时候,出现下面错误,进度条满了之后就没反应了.图例如以下: 引起这个问题的可能原因有非常多: 原因一:由于我们採用的是绝对路径定位.也就是说在环境变量里面把路径写死了, ...

  8. YARN简短的建筑

    从Hadoop的0.23版本号,MapReduce进行了全面的彻底的变革.也就是我们今天看到的MapReduce 2.0或者我们也能够叫它YARN. 老版本号的JobTracker有两个基本的功能:资 ...

  9. java通用抹去魔,在边界行动,擦除补偿

    java通用抹去魔 package org.rui.generics.erasure; public class HasF { public void f(){ System.out.println( ...

  10. ABP应用层——应用服务(Application services)

    ABP应用层——应用服务(Application services) 点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之15.ABP应用层——应用服务(Applic ...