随笔分类 -  sql

上一页 1 2 3 4 5 6 下一页
extended property
摘要:[代码]createschemaschema1goselect*fromsys.extended_propertieswheremajor_id=schema_id('schema1')go--createanextentedpropertyforschema1EXECsp_addextendedproperty@name=N'schemaDescription',@value='thisissc... 阅读全文
posted @ 2010-07-21 09:58 stswordman 阅读(369) 评论(0) 推荐(0) 编辑
create audit例子
摘要:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->--setupUSE MASTERGO-- Create the server auditCREA 阅读全文
posted @ 2010-01-04 18:08 stswordman 阅读(616) 评论(0) 推荐(0) 编辑
update lock
摘要:Update lock并不是一种单独的锁,而是shared lock和exclusive lock的混合体。 当数据库执行更新(insert, update, delete)操作时,会去尝试获得update lock. 整个更新操作可以分为两步:1 定位需要更新的数据,2 执行更新操作. 定位数据的步骤就是数据搜索的过程,我们可以将其想像成select,这时sqlserver会去尝试获得shared lock, 如果第一步成功,就会进入第二个阶段时,去获得exclusive lock,将之前获得的update lock转化(convert)成exclusive lock. 由于update l 阅读全文
posted @ 2009-09-14 17:34 stswordman 阅读(2282) 评论(1) 推荐(0) 编辑
Can we remove a single query plan
摘要:Can we remove a single query plan?You can use sp_recompile system stored procedure to clear it if the type of query plan is proc,trigger or functionElse you can't. If the received parameter of sp_reco... 阅读全文
posted @ 2009-08-10 16:44 stswordman 阅读(328) 评论(0) 推荐(0) 编辑
sql_handle and plan_handle (读书笔记)
摘要:SET option make different compiled plan For specific sql test, it always has the same sql_handle, but it may not always have the same plan_handle. If the cache keys change, we'll get a new plan_handle in plan cache. The relationship between sql_handle and plan_handle is thus 1:N 阅读全文
posted @ 2009-08-03 11:26 stswordman 阅读(2423) 评论(0) 推荐(0) 编辑
收缩日志文件视频演示代码&补充
摘要:http://technet.microsoft.com/zh-cn/dd939047(zh-cn).aspx最近收到了一些关于收缩日志的问题:已经执行了backup log命令,但执行shrink命令后仍然无法将日志文件收缩到指定大小,日志文件根本没有收缩/只收缩了一部分执行dbcc loginfo命令,可能会有如下结果您的日志尾部的虚拟日志文件为2状态。当执行dbcc shrinkfile命令后,38,39位置的虚拟文件会被立刻收缩掉,由于37位置的虚拟文件为2(数据库日志文件至少由一个状态为2的虚拟日志文件),所以不会被收缩掉,sqlserver会在37位置处添加哑日志记录(dummy 阅读全文
posted @ 2009-06-14 11:07 stswordman 阅读(370) 评论(0) 推荐(0) 编辑
透明加密视频演示代码
摘要:http://technet.microsoft.com/zh-cn/dd793599.aspx[代码] 阅读全文
posted @ 2009-04-27 16:13 stswordman 阅读(3440) 评论(0) 推荐(0) 编辑
table scan against heap with forward pointer
摘要:This post was published to stswordman at 6:09:31 PM 4/14/2009 table scan against heap with forward pointer Sql server维护了一个内部指针,它指向了表的第一个IAM页,还有一个执行表的首页的内部指针对一个表(heap)执行table scan时,sql server会按照IAM顺序查找... 阅读全文
posted @ 2009-04-14 18:18 stswordman 阅读(477) 评论(2) 推荐(0) 编辑
what's page are loaded into buffer pool for specified table
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->select * from sys.dm_os_buffer_descriptors bp inner join ( select OBJECT_ID,allocation_u... 阅读全文
posted @ 2009-04-13 11:45 stswordman 阅读(119) 评论(0) 推荐(0) 编辑
find the physical location for specified data row
摘要:[代码]http://www.sqlskills.com/BLOGS/PAUL/post/SQL-Server-2008-New-(undocumented)-physical-row-locator-function.aspx 阅读全文
posted @ 2008-12-11 14:41 stswordman 阅读(2414) 评论(0) 推荐(0) 编辑
record drop database in sql log
摘要:[代码] 阅读全文
posted @ 2008-12-10 15:59 stswordman 阅读(1529) 评论(0) 推荐(0) 编辑
sys.fn_dblog
摘要:sys.fn_dblog返回当前数据库日志的活动部分的内容Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->usedb1goifexists(select1fromsys.tableswherename='t')droptabletgocreatetablet(colint)godbcctraceon(3505,-1)---disable automatic checkpoint behaviorhttp://support.m 阅读全文
posted @ 2008-11-25 11:19 stswordman 阅读(3276) 评论(0) 推荐(0) 编辑
QA:附加数据库时,如果数据库主密钥的密码丢失怎么办?
摘要:当一个数据库被附加到一个新得sql server实例后,它的数据库主密钥(database master key)默认不会被服务器主密钥(service master key)保护.在这种情况下,我们需要自己修改这种状态,使它被服务器主密钥保护。但如果忘记了数据库主密钥得密码,则无法完成这项操作.如何解决这一问题:在原始实例上为db1的数据库添加新的密码,这样我们就可以在新的实例中使用这个密码了.在原始实例上执行一下代码:[代码]在新实例中:[代码] 阅读全文
posted @ 2008-10-12 22:06 stswordman 阅读(1198) 评论(0) 推荐(0) 编辑
运行sp_xp_cmdshell_proxy_account 出现的错误
摘要:运行sp_xp_cmdshell_proxy_account 存储过程可能出现以下几种错误:sp_xp_cmdshell_proxy_account 'domain\account','p@5$word'Msg 15137, Level 16, State 1, Procedure sp_xp_cmdshell_proxy_account, Line 1An error occurred during the execution of sp_xp_cmdshell_proxy_account.Possible reasons: the provided account was invalid 阅读全文
posted @ 2008-10-07 14:05 stswordman 阅读(2795) 评论(0) 推荐(2) 编辑
在SQL Server Agent中应用凭据
摘要:Sql server Agent是一种windows服务,用于执行各种管理任务。这些任务可能会涉及到一些对windows资源的访问(例如创建/删除文件等)。但是SQL Server中用户权限只在SQL Server范围内有效,无法扩展到SQL Server以外,这就意味着当执行job的安全上下文缺少相应权限时,job会失败。所以我们需要寻找另外一种方法来解决这个问题:凭据。首先看一下凭据的定义:凭据是包含连接到 SQL Server 外部资源所需的身份验证信息(凭据)的记录。此信息由 SQL Server 在内部使用。大多凭据都包含一个 Windows 用户名和密码。利用凭据中存储的信息,通过 阅读全文
posted @ 2008-10-06 10:38 stswordman 阅读(4946) 评论(7) 推荐(1) 编辑
something about trigger
摘要:To create a DML trigger requires ALTER permission on the table or view on which the trigger is being created. To create a DDL trigger with server scope (ON ALL SERVER) or a logon trigger requires CO... 阅读全文
posted @ 2008-09-07 23:15 stswordman 阅读(344) 评论(0) 推荐(0) 编辑
删除用户出现的错误
摘要:drop user u1 出现如下错误: Msg 15136, Level 16, State 1, Line 1 The database principal is set as the execution context of one or more procedures, functions, or event notifications and cannot be dropped. ... 阅读全文
posted @ 2008-08-28 15:21 stswordman 阅读(589) 评论(2) 推荐(0) 编辑
SQL Server 2005: About login password hashes
摘要:目前人们对于SQLSERVER处理登录密码的方式存在一些误解。希望阅读本文后,你能够对这些概念有清楚的认识。需要注意的是,只有SQL验证才会涉及到登录密码,WINDOWS验证模式不需要密码。第一个错误概念是SQLSERVER会对登录密码进行加密,然后储存起来。这是错误的。SQLSERVER存储的是经过HASH后的密码。HASH和加密的不同之处在于其难于反向破解--但是对于加密算法而言,只要掌握密钥就可以轻易获得明文。从HASH后的字符中找出原始明文是非常困难的(除非你已经知道了明文)。不选择加密而选择HASH的优点是无需保护密钥(参见之前的文章)。那么SQLSERVER是如何处理登录密码的呢? 阅读全文
posted @ 2008-08-11 00:57 stswordman 阅读(3006) 评论(8) 推荐(0) 编辑
xp_cmdshell
摘要:xp_cmdshell可以以SQLSERVER的上下文(也就是启动sqlserver服务的windows账户)或代理账户的上下文(通过为xp_cmdshell设置凭据)调用操作系统的任意命令。 xp_cmdshell非常灵活,实际上我想说它实在太灵活了,用户可以通过xp_cmdshell执行任何命令,并且没有什么好的方法可以去限制这种灵活性,这简直为它的滥用大行方便。在许多情况下,为了执行操作系统中的操作,人们开启了xp_cmdshell,并且授权那些非sysadmin角色的帐户可以去调用xp_cmdshell,但并没有认识到这些用户可以执行任意命令,在某些情况下,这些用户可以通过xp_cmd 阅读全文
posted @ 2008-08-04 00:40 stswordman 阅读(5078) 评论(4) 推荐(0) 编辑
OPEN SYMMETRIC KEY scope in SQL Server
摘要:最近我收到一些关于对称密钥有效范围的问题,特别是在模块内(存储过程)打开对称密钥。其中一个问题是,如果在存储过程内执行打开密钥(OPEN SYMMETRIC KEY)的操作,而退出存储过程前没有将密钥关闭,会导致密钥“泄露”到模块以外。在BOL的OPEN SYMMETRIC KEY(在备注下方)文章中,我们已经写明,打开的密钥在整个会话范文内有效,而仅仅是在执行上下文内(包括存储过程),并且密钥在被显示关闭(使用CLOSE SYMMETRIC KEY语句)或者会话终止前密钥都是处于打开状态的。如何保证密钥在模块内打开并且不会被“泄露”出去呢?需要显示密钥关闭。目前为止SQLSERVER 200 阅读全文
posted @ 2008-08-01 10:29 stswordman 阅读(3334) 评论(2) 推荐(0) 编辑

上一页 1 2 3 4 5 6 下一页