<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_潇湘隐者_分类_数据库技术(MS SQL)</title><id>http://feed.cnblogs.com/blog/u/57955/category/207300/rss</id><updated>2012-06-03T14:23:16Z</updated><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/category/207300.html"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/57955/category/207300/rss"/><entry><id>http://www.cnblogs.com/kerrycode/archive/2011/05/19/2050589.html</id><title type="text">SQL SERVER 表最小行的一个纠结问题</title><summary type="text">昨天一个同事突然问我，说他在SQL 2000数据库创建如下表的时候，突然碰到了下面一条警告信息。SQL脚本和警告信息如下：IFOBJECT_ID(N'Log')ISNULLBEGINCREATETABLELog([Date]DATETIME,[Thread]NVARCHAR(255),[Level]NVARCHAR(50),[Logger]NVARCHAR(255),[Message]NVARCHAR(4000),[Exception]NVARCHAR(4000))ENDELSEPRINT('该表已经存在，请检查数据库');GOWarning:Thetable&amp;</summary><published>2011-05-18T16:37:00Z</published><updated>2011-05-18T16:37:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2011/05/19/2050589.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2011/05/19/2050589.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2011/04/20/2022913.html</id><title type="text">三大数据库对比研究系列——数据类型</title><summary type="text">如果你经常在不同类型数据库做开发或学习时，切换数据库写脚本时，不同数据库的数据类型可能会让你有点“晕”。下面我将对Oracle、SQL Server 、MySql三种数据库的数据类型做下例举、比较SQL SERVER数据库暂且以SQL Server 2005为参考SQL SERVER 数据类型分的比较细： 整数数据、 字符数据、 货币数据、日期和时间数据、二进制字符串等 数据类型 所属类型 所占字节 范围 tinyint 精确数字类型 1字节 0 ~ 255 smallint 精确数字类型 2字节 -215(-32768)~215-1（32767） int 精确数字类型 4字节 -231 (-</summary><published>2011-04-20T14:10:00Z</published><updated>2011-04-20T14:10:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2011/04/20/2022913.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2011/04/20/2022913.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2011/03/23/1993149.html</id><title type="text">SQL 2000自定义函数调用GETDATE()报错</title><summary type="text">在SQL 2000数据库里的自定义函数中调用GETDATE()时,结果编译时报错，提示错误如下：Invalid use of 'getdate' within a function我给个测试例子如下所示，--================================================================================================-- Author : Kerry-- CreateDate : 2011-03-23-- Description : 根据规则自动生成流水号---------------------</summary><published>2011-03-23T14:38:00Z</published><updated>2011-03-23T14:38:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2011/03/23/1993149.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2011/03/23/1993149.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2011/03/13/1982878.html</id><title type="text">Access数据库问题锦集</title><summary type="text">很少采用Access做数据库开发，前段时间，朋友接了一个小单，让我帮忙做后台开发，采用Access + Asp.Net开发，结果在开发过程使用Access碰到不少问题，所以把这些问题总结一下，希望对其它人有些帮助1： Access分页脚本问题使用Access作为数据库开发系统时，页面数据分页的方案有好几种： 1.1 使用DataGridView自带的分页功能. 1.2. 使用SELECTTOP NOT IN 来实现。类似如下所示：SELECT TOP 100 [ID] , [Message] , [CreateDate]FROM ScrollMessageWHERE ID NOT IN ( S</summary><published>2011-03-13T11:07:00Z</published><updated>2011-03-13T11:07:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2011/03/13/1982878.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2011/03/13/1982878.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/12/27/1918218.html</id><title type="text">ROW_NUMBER () 与 PARTITION 组合妙用</title><summary type="text">前几天在一个群里面，有位网友问：在一个Book表里面里有字段AuthorID与Author表关联，现在要求按PublishDate字段倒序排列，列出每个作者的前五本书。要求有没有一条语句搞定的. 当时有个网友说不能一条语句解决问题，说只能用游标或临时表来解决。恰好我前阵子在整报表时遇到过类似的问题，当时解决过这个问题。当时我就告诉他用ROW_NUMBER与PARTITION来解决(前提是SQL SERVER 05或以上版本)。恰好现在有时间。正好把这个整理一下，即是对知识的梳理、巩固、总结，也希望能给其他人一些帮助建表脚本代码代码下面就是解决问题的脚本代码</summary><published>2010-12-27T10:32:00Z</published><updated>2010-12-27T10:32:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/12/27/1918218.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/12/27/1918218.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/12/27/1918101.html</id><title type="text">SQL Server 复制需要有实际的服务器名称才能连接到服务器</title><summary type="text">机子由于在捣鼓DAC连接方式时，计算机名被修改了，被改成了kerry，直到最近几天由于计算机改名了，这个潜在的问题（本机数据库只是偶尔那里做实验）终于爆发了:我用连接服务器从其它服务器拷贝数据时报错，错误如下：SQL Server 复制需要有实际的服务器名称才能连接到服务器。不支持通过服务器别名、IP 地址或任何其他备用名称进行连接。请指定实际的服务器名称“xxxx”。 (Replication.Utilities):具体情况如图所示解决方法：从sys.sysservers 查看列 svrname 可以发现不是新的计算机名，问题就出在此处(如图所示)。先用 sp_dropserver 删除服务</summary><published>2010-12-27T09:21:00Z</published><updated>2010-12-27T09:21:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/12/27/1918101.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/12/27/1918101.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/11/21/1883583.html</id><title type="text">T-SQL 编码标准【转帖】</title><summary type="text">本文转自：http://www.microsoft.com/china/msdn/library/data/sqlserver/sp04l9.mspx?mfr=true可能让人觉得很奇怪，但好像的确没有什么“正式的”T-SQL 编码标准。早在 1999 年末的时候，我惊喜地发现 John Hindmarsh 提出的 SQL Server 7.0 标准，我在 2000 年 2 月的社论中对他的某些建议进行了总结。（2000 年 2 月以及本月的“下载”中都包括了 John 原来的标准。）后来，Ron Talmage 撰写了一系列专栏文章，提出了他对各种“最佳方法”的建议，当然，SQL Serve</summary><published>2010-11-21T15:23:00Z</published><updated>2010-11-21T15:23:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/11/21/1883583.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/11/21/1883583.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/10/14/1851535.html</id><title type="text">SQL SERVER 的模糊查询 LIKE</title><summary type="text">今天写个动态脚本，需要把数据库里面包含“USER_"的表删除掉，突然想不起来如何搜索通配字符了，赶紧查查MSDN，整理了下模糊查询的知识点，留着以后查阅用。LIKE模糊查询的通配符 通配符 说明 示例 % 包含零个或多个字符的任意字符串。 WHERE title LIKE '%computer%'将查找在书名中任意位置包含单词"computer"的所有书名。 _（下划线） 任何单个字...</summary><published>2010-10-14T09:00:00Z</published><updated>2010-10-14T09:00:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/10/14/1851535.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/10/14/1851535.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/10/12/1848650.html</id><title type="text">慎用SELECT INTO复制表</title><summary type="text">很多时候我们习惯于用SELECTINTO复制一个表或表结构，因为它方便，快捷，而且在某些情况下效率比INSERT INTO 效率要高一些。但是要注意： SELECT INTO 复制表或表结构的时候，只是得到了一个“外壳”，就像克隆人一样，只是得到了一个躯体，个人的意识、回忆都不会克隆的。像原表的主键、外键、约束、触发器、索引都不会被复制过来。这点要注意哦，在某些情况下，没...</summary><published>2010-10-12T04:18:00Z</published><updated>2010-10-12T04:18:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/10/12/1848650.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/10/12/1848650.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/09/21/1832680.html</id><title type="text">SQL Server 2008 打SP1 补丁遇到的问题</title><summary type="text">今天在我机器上给SQL Server 2008 打上SP1补丁时，错误不断，郁闷死了。我的机器是XP Server Pack 3， SQL Server 2008 版本：SQL Server 2008 版本Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--...</summary><published>2010-09-21T09:05:00Z</published><updated>2010-09-21T09:05:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/09/21/1832680.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/09/21/1832680.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/09/21/1832593.html</id><title type="text">SQL Server 2008 筛选器报错Microsoft.SqlServer.Management.Sdk.Sfc</title><summary type="text">在Microsoft SQL Server 数据库中有时候经常需要筛选表，因为数据中表比较多时，不仅从一堆表里面找一个表比较麻烦，而且客户端从服务器加载这些信息需要一些时间。前两天安装了SQL Server 2008，结果在筛选表时，报如下错误：点击确定后，然后“表（已筛选）”，弹出如下错误提示。这个是因为没有打上SQL Server 2008 Service Pack 1...</summary><published>2010-09-21T06:53:00Z</published><updated>2010-09-21T06:53:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/09/21/1832593.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/09/21/1832593.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/09/18/1830071.html</id><title type="text">SQL Server数据库专用管理员DAC连接方式</title><summary type="text">SQL Server 提供了专用管理员链接（DAC）。DAC允许管理员访问运行的服务器以执行诊断函数或Transact—SQL语句，或对服务器上的问题进行故障排除，即使服务器以锁定或在非正常状态下运行。DAC默认情况下只有服务器上可以使用DAC，但是你可以通过 SQLServer 2005 外围应用配置器设置允许远程计算机上的客户端应用程序使用 DAC，如下图所示你也可以通过下面的SP...</summary><published>2010-09-18T03:38:00Z</published><updated>2010-09-18T03:38:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/09/18/1830071.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/09/18/1830071.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/09/09/1822329.html</id><title type="text">Microsoft OLE DB Provider for ODBC 组件</title><summary type="text">Microsoft OLE DB Provider for ODBC (MSDASQL) 一项允许在 OLEDB 和 ADO（它在内部使用 OLEDB）上构建的应用程序通过 ODBC 驱动程序访问数据源的技术。 MSDASQL 是用于连接到 ODBC（而不是数据库）的 OLEDB 访问接口。 MSDASQL 随 Windows 操作系统提供，Windows Server 2008 和 Window...</summary><published>2010-09-09T06:51:00Z</published><updated>2010-09-09T06:51:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/09/09/1822329.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/09/09/1822329.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/09/03/1816611.html</id><title type="text">数据库表的基本信息，你知道吗？</title><summary type="text">用SQL Doc生成数据库字典文档的时候，突然发现有字段描叙(Description)这项内容,以前一直没有注意过，故特意研究了一下,结果越挖越深，就写了这篇文章。以前在做数据库脚本开发时，新建表时，对各个字段的描叙要么是记录在文档里面，要么自己建一个表，来保存这些内容，以便日后开发、维护的方便。其实这些信息完全可以放在数据库自己的系统视图里面。对字段的说明、描述一般都放在系统视图sys.exte...</summary><published>2010-09-03T04:15:00Z</published><updated>2010-09-03T04:15:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/09/03/1816611.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/09/03/1816611.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/08/21/1804718.html</id><title type="text">SQL模板资源管理器，你用了吗？</title><summary type="text">SQL Server Management Studio 有个模板资源管理器，不知你用过没有？使用模板创建脚本、自定义模板等功能能大大提高你的工作效率，如果没有尝试过，赶紧去试试吧。很多时候，我们习惯了手写脚本，而不愿意花费精力去研究陌生的工具。你可以在通过下面方式打开模板资源管理器 视图-&gt;模板资源管理器; 也可以通过快捷键CTRL + ALT + T打开它。如图所示，你可以看见里面已经包...</summary><published>2010-08-21T13:30:00Z</published><updated>2010-08-21T13:30:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/08/21/1804718.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/08/21/1804718.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/08/16/1800334.html</id><title type="text">如何书写优雅、漂亮的SQL脚本？</title><summary type="text">本篇来聊聊如何书写漂亮、整洁、优雅的SQL脚本，下面这些是我个人总结、整理出来的。姑且做个抛砖引玉吧，呵呵，欢迎大家一起来讨论。我们首先来看看一段创建数据表的脚本(如下所示)，你是否觉得有什么不妥或是不足呢？如果是你，你怎样书写呢?代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHig...</summary><published>2010-08-16T00:40:00Z</published><updated>2010-08-16T00:40:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/08/16/1800334.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/08/16/1800334.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/08/14/1799392.html</id><title type="text">SQL Server——存储过程</title><summary type="text">我想从下面几个方面大概的讲述下存储过程，可能有些知识点是你没有注意的，也可能有些知识点我不知道，欢迎大家指点指点。如有不足，欢迎指教!存储过程概念存储过程优点存储过程的接口存储过程的解析、编译过程存储过程安全性查看存储过程加密、解密存储过程存储过程概念存储过程(Stored Procedure)是一组为了完成特定功能的SQL语句集，经编译后存储在数据库中。用户通过指定存储过程的名字并给出参数(带参...</summary><published>2010-08-13T17:10:00Z</published><updated>2010-08-13T17:10:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/08/14/1799392.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/08/14/1799392.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/08/05/1792671.html</id><title type="text">SQL Server ——动态SQL</title><summary type="text">动态SQL：code that is executed dynamically。它一般是根据用户输入或外部条件动态组合的SQL语句块。动态SQL能灵活的发挥SQL强大的功能、方便的解决一些其它方法难以解决的问题。相信使用过动态SQL的人都能体会到它带来的便利，然而动态SQL有时候在执行性能(效率)上面不如静态SQL，而且使用不恰当，往往会在安全方面存在隐患(SQL 注入式攻击)。动态SQL可以通过...</summary><published>2010-08-04T16:06:00Z</published><updated>2010-08-04T16:06:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/08/05/1792671.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/08/05/1792671.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/07/28/1786547.html</id><title type="text">重温SQL——行转列，列转行</title><summary type="text">行转列，列转行是我们在开发过程中经常碰到的问题。行转列一般通过CASE WHEN 语句来实现，也可以通过 SQL SERVER 2005 新增的运算符PIVOT来实现。 用传统的方法，比较好理解。层次清晰，而且比较习惯。 但是PIVOT 、UNPIVOT提供的语法比一系列复杂的 SELECT...CASE 语句中所指定的语法更简单、更具可读性。下面我们通过几个简单的例子来介绍一下列转行、行转列问题...</summary><published>2010-07-28T00:40:00Z</published><updated>2010-07-28T00:40:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/07/28/1786547.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/07/28/1786547.html"/><content type="html"/></entry><entry><id>http://www.cnblogs.com/kerrycode/archive/2010/07/27/1785475.html</id><title type="text">DATEDIFF函数小问题</title><summary type="text">DATEDIFF函数语法如下DATEDIFF( datepart , startdate , enddate )，返回指定的 startdate 和 enddate 之间所跨的指定 datepart 边界的计数（带符号的整数）。下面来说说我碰到的这个问题。用户表里user里面有个字段Create_Time记录用户注册日期，Last_Login_Time 记录用户最后登录的时间，要统计注册用户在注册...</summary><published>2010-07-27T00:20:00Z</published><updated>2010-07-27T00:20:00Z</updated><author><name>潇湘隐者</name><uri>http://www.cnblogs.com/kerrycode/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kerrycode/archive/2010/07/27/1785475.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kerrycode/archive/2010/07/27/1785475.html"/><content type="html"/></entry></feed>
