博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年9月27日

摘要: 存在即更新,反之插入的需求是很常见的,很多人没有注意并发的问题,高并发下为了避免唯一键冲突和死锁情况,下面提供三种写法,最后一个是sql server 2008及以后版本适用。示例表为:usetempdbgocreatetabletb_1(idintidentityprimarykey,avarchar(50),dtdatetimedefaultgetdate())go写法一:begintranifexists(select*fromtb_1with(updlock,serializable)whereid=100)beginupdatetb_1seta='a100'where 阅读全文

posted @ 2011-09-27 14:45 nzperfect 阅读(3080) 评论(5) 推荐(1) 编辑

2011年9月26日

摘要: 最近遇到一个update时产生死锁的情况,两条一模一样的sql同时执行时,居然会产生Deadlock。windows 2003 server x64 + sql server 2008 sp2 Enterprise X64 示例(实际环境与该表相似):当两个进程同时执行下面的语句时,在高并发下会产生死锁:updatettwith(rowlock)setc='eb',d='cc'wherea='84B23855-2155-4EE0-911D-38D1265F1655'示例表结构:usetempdbgocreatetablett(idintident 阅读全文

posted @ 2011-09-26 17:15 nzperfect 阅读(3849) 评论(5) 推荐(1) 编辑

2011年8月31日

摘要: 每天win7的Windows Search服务一开启,outlook就半天无响应,干脆关了这个服务作两个批处理,一个是开启,一个是关闭1.在windows开机脚本里,添加开启的批处理,这样一开机就关闭此服务2.设置windows计划任务,12:00启用,13:00开关,中午这段时间Windows Search建索引。 rem停止win7的WindowsSearch服务netstopwsearchscconfig"wsearch"start=disabled rem开启win7的WindowsSearch服务scconfig"wsearch"start=a 阅读全文

posted @ 2011-08-31 14:42 nzperfect 阅读(1895) 评论(0) 推荐(0) 编辑

2011年7月28日

摘要: 参考:http://www.mssqltips.com/tip.asp?tip=2444 取硬盘大小及可用空间declare@svrNamevarchar(255)declare@sqlvarchar(400)--bydefaultitwilltakethecurrentservername,wecanthesettheservernameaswellset@svrName=casecharindex('\',@@servername)when0then@@servernameelseleft(@@servername,charindex('\',@@serve 阅读全文

posted @ 2011-07-28 16:09 nzperfect 阅读(490) 评论(2) 推荐(0) 编辑

2011年6月16日

摘要: EXEC sp_resetstatus 'DBname';ALTER DATABASE DBname SET EMERGENCYDBCC checkdb('DBname')ALTER DATABASE DBname SET SINGLE_USER WITH ROLLBACK IMMEDIATEDBCC CheckDB ('DBname', REPAIR_ALLOW_DATA_LOSS)ALTER DATABASE DBname SET MULTI_USER参考:http://www.codeproject.com/KB/reporting-ser 阅读全文

posted @ 2011-06-16 15:56 nzperfect 阅读(444) 评论(0) 推荐(0) 编辑

2011年6月14日

摘要: 4G 内存 32bit win2k3+sql2k8 sp1运行一段时间后,在添加字段或修改字段长度时:Failed to initialize the Common Language Runtime (CLR) v2.0.50727 with HRESULT 0x80004005. You need to restart SQL Server to use CLR integration features.重启SQL Server后,error有:AppDomain 2 (mssqlsystemresource.dbo[runtime].1) created.AppDomain 3 (mss. 阅读全文

posted @ 2011-06-14 13:56 nzperfect 阅读(1767) 评论(0) 推荐(0) 编辑

2011年6月10日

摘要: How to add an article to an existing Transactional Subscription initialized through backup添加新表:1.将要发布的新表添加至已存在发布项,之后再将其删除,这样操作,可以避免考虑not for replication问题2.在发布库生成该表的create脚本,到订阅库去执行来生成该表3.停止 logreader job.4.使用ssis等方法将该表数据从发布库导入订阅库,注意,确保该表在导数据期间和在添加到发布项之前,不能再有改变,否则需要再用tablediff来追数据5.将该表使用界面或脚本添加至已存在的 阅读全文

posted @ 2011-06-10 15:01 nzperfect 阅读(320) 评论(0) 推荐(0) 编辑

2011年6月9日

摘要: 初始化订阅: 1.使用界面在发布服务器上建立发布项,勾选“立即创建快照并使快照保持可用状态,以初始化订阅”。 即: @immediate_sync = N'true'2.使用界面修改发布项的"允许从备份文件初始化"为true. 即:@allow_initialize_from_backup = N'true'3.为前发布数据库全一个全备,一个事务log备份'd:\DBBak\repl.trn'4.在订阅服务器用发布库全备还原出一个订阅库,状态norecovery,之后再还原发布的log备份,状态recovery5.使用脚本命令 阅读全文

posted @ 2011-06-09 15:48 nzperfect 阅读(540) 评论(0) 推荐(0) 编辑

2011年6月1日

摘要: 最近在用SSIS导数据时遇到RESOURCE_SEMAPHORE等待,之后挂起。源服务器4G内存,SQL Server 2005 sp3 企业版,8核目标服务器10台,配置同上现在要在10台服务器上执行SSIS来抽取源服务器数据,数据量小时未发现异常,抽的数据量大时,出现RESOURCE_SEMAPHORE等待,然后SSIS进程挂起,导数据停滞,经查msdn,如下:http://msdn.microsoft.com/zh-cn/library/ms179984.aspxRESOURCE_SEMAPHORE当由于存在其他并发查询而无法立即批准查询内存请求时出现。等待时间较长或等待次数较多可能指示 阅读全文

posted @ 2011-06-01 19:38 nzperfect 阅读(1015) 评论(1) 推荐(0) 编辑

2011年2月17日

摘要: 我的版本是0.8.7d,这个问题已经好久没有找到办法解决,最近将cacti从0.8.7d升级为0.8.7e,但还是报插入重复键错误最后仔细找了下原因,终于解决了: SPINE: Poller[0] ERROR: SQL Failed! Error:'1062', Message:'Duplicate entry '68-cpu-2011-02-16 18:00:03' for key 1'如图: 由于之前安装的是cacti 0.8.7d for windows版本,不知道是版本本身的bug还是配置的问题,一直出现已添加的host主机不能删除的情况,后来索性就手工到mysql内删除,但由于对ca 阅读全文

posted @ 2011-02-17 11:10 nzperfect 阅读(2270) 评论(0) 推荐(0) 编辑

2010年12月22日

摘要: http://connect.microsoft.com/SQLServer/feedback/details/334180/data-collector-remove-data-collector-to-remove-associated-objectsAfter the data collector is configured, the data collector can be disabled but not removed. This means that all objects created by the data collector will remain on the ins 阅读全文

posted @ 2010-12-22 16:21 nzperfect 阅读(1370) 评论(0) 推荐(0) 编辑

2010年11月26日

摘要: FIX: "There is insufficient system memory in resource pool 'internal' to run this query" error message when you run a full-text query that uses compound words in Microsoft SQL Server 2008 or in Micros... 阅读全文

posted @ 2010-11-26 10:54 nzperfect 阅读(2371) 评论(0) 推荐(0) 编辑

2010年11月25日

摘要: 11度春春系列电影:《老男孩》[hjp2=600,460,true]http://player.youku.com/player.php/sid/XMjE4MDU1MDE2/v.swf [/hjp2]是否让你想起了太多的往事?是否有很多的感慨呢? 那是我日夜思念深深爱着的人呐到底我该如何表达她会接受我吗?也许永远都不会跟她说出那句话注定我要浪迹天涯怎么能有牵挂梦想总是遥不可及是不是应该放弃花开花落... 阅读全文

posted @ 2010-11-25 13:24 nzperfect 阅读(514) 评论(0) 推荐(0) 编辑

2010年11月24日

摘要: IntroductionEver wondered which program has a particular file or directory open? Now you can find out. Process Explorer shows you information about which handles and DLLs processes have opened or load... 阅读全文

posted @ 2010-11-24 15:52 nzperfect 阅读(526) 评论(1) 推荐(0) 编辑

2010年7月1日

摘要: 原址:http://blog.csdn.net/Garnett_KG/archive/2010/05/22/5615865.aspx 阅读全文

posted @ 2010-07-01 10:13 nzperfect 阅读(445) 评论(1) 推荐(0) 编辑

2010年6月1日

摘要: SQL Server 2008 R2 Pricing原文:http://www.microsoft.com/sqlserver/2008/en/us/pricing.aspxMicrosoft SQL Server licensing provides the option to purchase SQL Server 2008 R2 under a Server/CAL licensing mo... 阅读全文

posted @ 2010-06-01 16:32 nzperfect 阅读(531) 评论(0) 推荐(0) 编辑

2010年5月28日

摘要: 很久没写blog,不是懒,实在是最近我这的访问速度不好,用firefox经常上传不了图片 .......今天无意发现了SQL Server 2008 Datetime Cast 成 Date 类型可以使用索引,分享一下:测试环境:[代码]由上面的T-sql可以看出,如果我们查 2010年5月27的数据,应该只有一条。为了更明显说明以下四种写法的区别,打开IO/执行计划开关,并且选中执行结果包含实际... 阅读全文

posted @ 2010-05-28 17:29 nzperfect 阅读(3915) 评论(11) 推荐(5) 编辑

2010年4月29日

摘要: 以下仅为参照,如果有多个实例,可能会有些许不同:本环境是SQLServer2005StandardVersion64-bit 和 SQLServer2008 StandardVersion64-bit 双实例同时安装在一个WindowsServer2008StandardVersion64-bit OS上:代码Code highlighting produced by Actipro CodeHi... 阅读全文

posted @ 2010-04-29 23:19 nzperfect 阅读(12381) 评论(5) 推荐(1) 编辑

2010年4月16日

摘要: Database Mirroring Log Compression in SQL Server 2008 Improves Throughput Author: Sanjay Mishra Reviewers: Peter Byrne, Don Vilen, Kaloian Manassiev, Burzin Patel, Eric Jacobsen Overview Da... 阅读全文

posted @ 2010-04-16 14:04 nzperfect 阅读(581) 评论(1) 推荐(0) 编辑

摘要: 原文:http://www.karaszi.com/SQLServer/info_dont_shrink.asp Overview If you want the really reallyshort story, then check out this analogy - hopefully you come back here and read the full story. Introd... 阅读全文

posted @ 2010-04-16 13:59 nzperfect 阅读(508) 评论(0) 推荐(0) 编辑

2010年4月14日

摘要: Following statement can reset seed[代码]but can't reset increment.how change the identity increment of column?I can't find the simple method,now I use Following sql script to change it.[代码]please tell m... 阅读全文

posted @ 2010-04-14 16:35 nzperfect 阅读(349) 评论(0) 推荐(0) 编辑

2010年3月30日

摘要: 查找未使用的非聚集索引和未使用的表.DMV:sys.dm_db_index_usage_statsThe counters are initialized to empty whenever the SQL Server (MSSQLSERVER) service is started. In addition, whenever a database is detached or is shut... 阅读全文

posted @ 2010-03-30 15:03 nzperfect 阅读(508) 评论(0) 推荐(0) 编辑

2010年3月29日

摘要: 原文:http://blogs.msdn.com/suhde/archive/2009/05/20/lock-pages-in-memory-now-available-for-standard-edition-of-sql-server.aspxDue to over-whelming customer demand for the "Lock pages in memory" support for the Standard Edition of SQL Server 2005 and 2008, Microsoft has released Cumulative Up 阅读全文

posted @ 2010-03-29 10:32 nzperfect 阅读(2699) 评论(0) 推荐(1) 编辑

2010年3月25日

摘要: Index related DMVs and DMFs - sys.dm_db_index_usage_stats By : Dinesh Priyankara Oct 09, 2007 Examining statistics of indexes is usefulforoptimizingthe performance of queries. Statistics help us d... 阅读全文

posted @ 2010-03-25 16:59 nzperfect 阅读(1037) 评论(0) 推荐(0) 编辑

2010年3月24日

摘要: How to recreate the msdb database in SQL Server 2005? I've just spenta bunchtime researching an answer tothis question on the new disaster recovery forumbecause I couldn't find any definitive ... 阅读全文

posted @ 2010-03-24 17:48 nzperfect 阅读(370) 评论(0) 推荐(0) 编辑

2010年3月13日

摘要: By Mike Garcen (ShadyMG) | Published Wednesday, 22 July 2009 In honor of Windows7 hitting the big RTM (release to manufacturing) milestone, I figured it best to start fresh with this Guide and archive... 阅读全文

posted @ 2010-03-13 19:06 nzperfect 阅读(1617) 评论(0) 推荐(0) 编辑

2010年3月12日

摘要: Determining the appropriate memory configuration for a SQL Server platform is a task that all database administrators are required to perform. It is essential to ensuring that an appropriate level o... 阅读全文

posted @ 2010-03-12 14:48 nzperfect 阅读(705) 评论(0) 推荐(0) 编辑

2010年3月3日

摘要: An update for Standard SKU Support for Locked Pages…. Note this article has been updated to include an update for SQL Server 2005 I posted in April that we would be releasing cumulative update... 阅读全文

posted @ 2010-03-03 17:37 nzperfect 阅读(602) 评论(0) 推荐(0) 编辑

摘要: Fun with Locked Pages, AWE, Task Manager, and the Working Set… I realize that the topic of “locked pages’ and AWE can be confusing. I don’t blame anyone for being confused on... 阅读全文

posted @ 2010-03-03 17:30 nzperfect 阅读(710) 评论(0) 推荐(0) 编辑

2010年2月25日

摘要: 为什么行排它锁仍无法锁住其它进程去select该数据行?例:表tmp,10000条数据,id为主键.在进程一(spid=55)中执行:在进程二(spid=64)中执行:查看锁信息: 可以看到进程二对id=10这行的S锁并不会被进程一中的X锁锁住,这似乎与微软所说的共享锁和排它锁不兼容冲突了,为什么? 解释:在一般情况下,当SQL Server使用默认的锁定方式(行级锁)读取一行记录时,需要依次在相... 阅读全文

posted @ 2010-02-25 17:14 nzperfect 阅读(1480) 评论(2) 推荐(1) 编辑

摘要: 今天在做发布订阅时,又出现了以前遇到过的一个问题:"SELECT失败,因为下列SET选项的设置不正确:'ANSI_PADDING'。请确确保SET选项正确无误,可以用于计算列上的索引视图和/或索引......"如下图:在一个库里有很多表,在发布时,发现该库有两个表存在这个问题,经过比对生成的快照.sch文件内容,发现出错的表的生成的结构信息的.sch内容有:SET ANSI_PADDING OFF... 阅读全文

posted @ 2010-02-25 16:49 nzperfect 阅读(1918) 评论(0) 推荐(0) 编辑

2010年1月13日

摘要: 原代码地址:http://www.sqlskills.com/blogs/Kimberly/post/Updates-(fixes)-to-sp_helpindex2.aspxsp_helpindex2 for sql server 2005:[代码]sp_helpindex2 for sql server 2008(我已修正bug)[代码]在sp_helpindex for sql server... 阅读全文

posted @ 2010-01-13 09:48 nzperfect 阅读(650) 评论(0) 推荐(0) 编辑

2009年10月21日

摘要: 一台测试环境的sql server 2008 fulltext不能填充,log内显示如下:The fulltext filter daemon host (FDHost) process has stopped abnormally. This can occur if an incorrectly configured or malfunctioning linguistic component... 阅读全文

posted @ 2009-10-21 12:49 nzperfect 阅读(1822) 评论(0) 推荐(0) 编辑

2009年10月18日

摘要: 源于csdn论坛的一个提问:[代码]通过一个查询看下扫描的数据页:[代码]可以看到,该查询全部数据是扫了四个数据页,也就是说插入的四行数据,一行为一个page.但是我们执行下面的sql,发现index_size为8k:[代码]这是为什么,为什么没有建索引,这里却有一个index_size 8k ?下面来看看index_size是怎么来的?首先想到是的[代码]通过查看sp_spaceused的代码,... 阅读全文

posted @ 2009-10-18 22:23 nzperfect 阅读(2059) 评论(0) 推荐(0) 编辑

2009年10月15日

摘要: 这个问题源于csdn一贴子,后来发现sql server各版本对这个case when else end结果的处理不尽相同。。CASE语法如下:[代码]联机文档有文:结果类型:从 result_expressions 和可选 else_result_expression 的类型集中返回优先级最高的类型。有关详细信息,请参阅 数据类型优先级,如下[代码]下面准备测试数据及开始测试:[代码]我以上的测... 阅读全文

posted @ 2009-10-15 14:07 nzperfect 阅读(4581) 评论(8) 推荐(2) 编辑

2009年9月27日

摘要: 当数据库出现页损坏或校验和出错时如何处理作者:nzperfect / perfectaction日期:2009.09.27最近一直在进一步学习数据库故障的处理方面的知识,做为一个数据库维护人员,我即期望遇到所有的数据库出错的案例,以增加自己的经验,但同时又担心遇到这样或那样无法处理的数据库故障而导致数据丢失。 前几天看到一个文章,是说一个网站管理员在招聘DBA时,提出一个问题:“如果在... 阅读全文

posted @ 2009-09-27 16:47 nzperfect 阅读(2821) 评论(8) 推荐(0) 编辑

2009年8月25日

摘要: [代码] 阅读全文

posted @ 2009-08-25 17:17 nzperfect 阅读(658) 评论(0) 推荐(0) 编辑

2009年8月24日

摘要: 试验环境:VMware + Windows2003 中文企业版 + sql server 2008 中文企业版共用了7台虚拟机:域控机共享备份机(存放主库log shipping备份日志文件)主服务器镜像服务器分发服务器log shipping服务器订阅服务器在我的个人老PC上 : AMD 2000+、1.5G内存、80G 5400转硬盘 安装的虚拟机我的PC cpu一直在100%,相当的累。对虚... 阅读全文

posted @ 2009-08-24 11:09 nzperfect 阅读(1523) 评论(7) 推荐(0) 编辑

2009年8月14日

摘要: 昨天,查看cacti日志,发现有大量提示:08/12/2009 07:20:00 AM - POLLER: Poller[0] WARNING: Poller Output Table not Empty. Issues Found: 27, Data Sources: hdd_used(DS[80]), hdd_total(DS[86]), hdd_total(DS[132]), hdd_total(DS[136]), hdd_total(DS[142]), hdd_total(DS[150]), hdd_total(DS[186]), hdd_total(DS[192]), hdd_tot 阅读全文

posted @ 2009-08-14 13:59 nzperfect 阅读(5475) 评论(0) 推荐(0) 编辑

2009年7月30日

摘要: 今天看cacti监控,发现昨天没取到数据看下日志,出现大量错误ERROR: SQL Assoc Failed!, Error:'145',如图:将sql执行结果显示表出错,如图:如上图,显示表poller_output 需要修复,查了下网上有很多例子,试了一个,解决,如图:之后再查询正常:问题解决.以下为网上找的:------------------------------------------... 阅读全文

posted @ 2009-07-30 14:05 nzperfect 阅读(2081) 评论(0) 推荐(0) 编辑