随笔分类 -  SQLSERVER

摘要:From :http://sqlblog.com/blogs/maria_zakourdaev/archive/2012/05/11/sqlcmd-mode-give-it-one-more-chance.aspx?utm_source=tuicool- Click on me. Choose me... 阅读全文
posted @ 2014-09-24 11:46 Vincent.Dr 阅读(388) 评论(0) 推荐(0)
摘要:e.g:DECLARE @xmlSource XMLSET @xmlSource = ' 'SELECT @xmlSource.query('data(//@*)');SELECT @xmlSource.query('for $nodes in //*, $attr in $nod... 阅读全文
posted @ 2014-05-01 21:05 Vincent.Dr 阅读(1089) 评论(0) 推荐(0)
摘要:This info is from:http://www.codeproject.com/Articles/302405/The-Easy-way-of-changing-Collation-of-all-DatabaseHave you encountered a problem where you wanted to change your database collation to default or even just change it to a different type? I guess what you had initially done (like me) was to 阅读全文
posted @ 2013-11-26 12:12 Vincent.Dr 阅读(365) 评论(0) 推荐(0)
摘要:1.将.MDF和.LDF文件拷到SQL Server2008数据目录,如:\\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA;2. 然后在SQL Server Management Studio 右击Datebases,选择Attach附加数据库,然后按提示ADD你刚刚添加的那个.MDF文件即可。 阅读全文
posted @ 2013-10-09 15:21 Vincent.Dr 阅读(968) 评论(0) 推荐(0)
摘要:转自:http://www.connectionstrings.com/SQL ServerODBCStandard Security:"Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"Trusted connection:"Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connection=yes;"PRompt for username and passWord:oConn.Properties(&quo 阅读全文
posted @ 2013-10-04 16:38 Vincent.Dr 阅读(228) 评论(0) 推荐(0)
摘要:SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTEDSELECT TOP 30ROUND(s.avg_total_user_cost * s.avg_user_impact * ( s.user_seeks+ s.user_scans ),0) AS [Total Cost] ,s.avg_total_user_cost * ( s.avg_user_impact / 100.0 ) * ( s.user_seeks+ s.user_scans ) AS Improvement_Measure ,DB_NAME() AS DatabaseName , 阅读全文
posted @ 2013-08-05 19:08 Vincent.Dr 阅读(350) 评论(0) 推荐(0)
摘要:现象:Web服务器中SQL Server占用内存非常高,加内存后,SQL Server又吃掉新加的内存,好像内存永远不够用一样。分析:其实这并不一定是由于SQL Server活动过度造成的,在启动SQL Server后,SQL Server内存使用量会持续稳定上升,即使服务器上活动很少也不会下降,直到物理内存仅剩下4到10M为止,这是SQL Server缓冲池的预期行为,正常现象。解决:不过这种现象使得服务器应付峰值的能力降低,当突然有较大的活动时,可能使得服务器当机。要限制缓冲池的内存使用量,可以打开“SQL Server属性”->“内存”,在这一页中降低“最大值”,点击“确定”。点击 阅读全文
posted @ 2013-08-02 11:43 Vincent.Dr 阅读(1563) 评论(0) 推荐(0)
摘要:内存管理器输出的第一节是内存管理器。此部分将显示 SQL Server 的总内存消耗。 Memory Manager KB ------------------------------ -------------------- VM Reserved 1761400 VM Committed 1663556 AWE Allocated 0 Reserved Memory 1024 Reserved... 阅读全文
posted @ 2013-08-01 19:14 Vincent.Dr 阅读(373) 评论(0) 推荐(0)
摘要:select * from sys.sysprocesses where blocked0看看waittime是不是很大kill spid 阅读全文
posted @ 2013-07-30 19:22 Vincent.Dr 阅读(153) 评论(0) 推荐(0)
摘要:什么是死锁?==============A deadlock occurs when two system server process IDs (SPIDs) are waiting for a resource and neither process can advance because the other process is preventing it from getting the resource. For example, Andrew holds a lock on table A and requests a lock on table B; Lindsay holds 阅读全文
posted @ 2013-06-03 14:27 Vincent.Dr 阅读(333) 评论(0) 推荐(0)
摘要:1. 与SQL相关的timeout, 都是由Client端发起的.比如说, 我们自己写了个C#小程序, 其中使用了SqlCommand.CommandTimeout属性, 指定它的值为20秒. 那么, 当这个query在SQL端执行了二十秒后, 我们的C#小程序会给SQL Server发送一个TDS Tension数据包, 告诉SQL Server我这边超时了, 你那边的query不用做了. 于是SQL相应client的请求, 断掉connection. Client端报出一条exception, 说SQL Server端的运行时间太长, 超过了我们原定的时限.2. 那么SQL Server 阅读全文
posted @ 2013-06-03 11:52 Vincent.Dr 阅读(1444) 评论(0) 推荐(0)
摘要:NOLOCK============使用NOLOCK, 你会告诉SQL Server去忽略掉locks, 直接从表中读取数据. 这意味着你规避了SQL Server的锁系统, 会大幅度地提高性能和可扩展性.然而, 既然你完全地绕过了锁系统, 也就意味着你的代码存在着读取了脏数据的风险. 你也许会读取到没有在一个transaction中被committed的不合法的数据. 这很危险.ROWLOCK============使用ROWLOCK, 你会告诉SQL Server去仅仅使用row-level的lock. 在SELECT, UPDATE, 和DELETE语句中, 你可以使用这个关键字, 但是 阅读全文
posted @ 2013-06-03 11:36 Vincent.Dr 阅读(243) 评论(0) 推荐(0)
摘要:---solution---Using script to query the repl config as below:SELECT * FROM sys.configurations WHERE NAME LIKE'%repl%'Using script update the repl config as below:sp_configure 'max text repl size', 483647 reconfigure with override 阅读全文
posted @ 2013-02-27 14:57 Vincent.Dr 阅读(315) 评论(0) 推荐(0)
摘要:DECLARE @Customer_Name VARCHAR(500)DECLARE perCursor CURSOR FOR SELECT Name FROM PersonOPEN perCursorFETCH NEXT FROM perCursor into @Customer_Name WHILE @@FETCH_STATUS = 0 BEGIN print @Customer_Name FETCH NEXT FROM perCursor into @Customer_Name ENDCLOSE perCursorDEALLOCATE perCursor 阅读全文
posted @ 2013-01-11 12:42 Vincent.Dr 阅读(165) 评论(0) 推荐(0)