随笔分类 - SQL Server
摘要:select '参数名称' = name, '参数类型' = type_name(xusertype), '参数长度' = length, '参数顺序' = colid, '是否输出参数'=isoutparam from syscolumns where id=object_id('存储过程名称')
阅读全文
摘要:出现名为'MM_CURSOR' 的游标已存在。一般出现这样的问题是:1:游标没有 --关闭 释放如:Sql代码--关闭游标CLOSEMM_CURSOR--释放游标DEALLOCATEMM_CURSOR2:游标已存在同名情况,此时就需要在定义游标时申明一个局部的游标如:Sql代码/*检索已经配置好的新村镇的所有乡级部门*/---申明游标DECLAREdeptCursorCURSORlocalFORSELECTdeptname,deptsimplename,distid,deptuncode,deptqueryno,ifreport,deptsort,enable,deptfloo
阅读全文
摘要:检测死锁如果发生死锁了,我们怎么去检测具体发生死锁的是哪条SQL语句或存储过程?这时我们可以使用以下存储过程来检测,就可以查出引起死锁的进程和SQL语句。SQL Server自带的系统存储过程sp_who和sp_lock也可以用来查找阻塞和死锁, 但没有这里介绍的方法好用。 use mastergocreate procedure sp_who_lockasbegindeclare @spid int,@bl int,@intTransactionCountOnEntry int, @intRowcount int, @intCountProperties int, @intCounter i
阅读全文
摘要:基于Query方法declare @myDoc xmlset @myDoc = '<bookstore> <book category="COOKING"> <title>Everyday</title> <author>Giade De</author> <price>30.00</price> </book> <book category="COMPUTER"> <title>Windows 2003</t
阅读全文
摘要:(1)索引XML字段最大支持2G,如果不建立索引,遍历数据查询,性能会很差。Primary Index 必须有主键列,且为聚集索引。该索引中存放XML数据中Tag、Value和Path等信息辅助Path Index 用于基于Path查询,即XPath查询辅助Property Index 用于基于节点的查询辅助Value Index 用于XML值的查询XQuery即查询XML语言,包括基于XPath、Element和Attribute语法包括FLOWRFor 遍历满足条件节点的内容Let Order By Where Return(2)索引查询原始数据 CREATE TABLE Orde...
阅读全文
摘要:(1)定义--表中定义CREATE TABLE [dbo].[Invoice]( [Invoice_ID] [int] NULL, [SalesDate] [date] NULL, [ItemList] [xml] NULL ) --程序中定义declare @xdoc xml;--隐式类型转换SET @xdoc =’<Customer CustomerID="VINET" ContactName="Paul Henriot"> <Order CustomerID="VINET" EmployeeID="5
阅读全文
摘要:declare @xdoc xml; SET @xdoc =' <ROOT> <Customer CustomerID="VINET" ContactName="Paul Henriot"> <Order CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00"> <OrderDetail OrderID="10248" ProductID="
阅读全文
摘要:原始数据:(1)非元素Raw模式联合查询SELECT P.Product_Name,P.ListPrice,S.Quantity FROM Products PJOIN Sales SON S.Product_ID=P.Product_IDFOR XML RAW显示结果<row Product_Name="Dell笔记本" ListPrice="3500.00" Quantity="100" /><row Product_Name="Apple笔记本" ListPrice="5000.0
阅读全文
摘要:一、以记录为核心(1)path模式select * from 表名for xml path执行结果<row> <TreeNode_ID>2</TreeNode_ID> <TreeNode_Name>1</TreeNode_Name></row>(2)raw模式select * from 表名for xml raw执行结果<row TreeNode_ID="2" TreeNode_Name="1" />(3)auto模式select * from 表名for xml aut
阅读全文

浙公网安备 33010602011771号