Loading

随笔分类 -  sql server

摘要:SELECT 表名 = case when a.colorder=1 then d.name else '' end, 表说明 = case when a.colorder=1 then isnull(f.value,'') else '' end, 字段序号 = a.colorder, 字段名 = a.name, 标识 = case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end, 主键 = case whe 阅读全文
posted @ 2011-05-29 20:54 .net's 阅读(632) 评论(0) 推荐(0)
摘要:ALTER PROCEDURE [dbo].[aspnet_Membership_FindUsersByEmail] @ApplicationName nvarchar(256), @EmailToMatch nvarchar(256), @PageIndex int, @PageSize intASBEGIN DECLARE @ApplicationId uniqueidentifier SEL... 阅读全文
posted @ 2011-03-11 17:03 .net's 阅读(405) 评论(0) 推荐(0)
摘要:I have received call from my DBA friend who read my articleSQL SERVER – 2005 – Introduction to Partitioning. He suggested that I should write simple tutorial about how to horizontal partition database table. Here is simple tutorial which explains how a table can be partitioned. Please read my articl 阅读全文
posted @ 2011-03-10 17:09 .net's 阅读(604) 评论(0) 推荐(0)
摘要:【鹏城万里】 发表于www.sqlstudy.comSQL Server 2005 分区表实践——建立分区表(partition table)问题:有一个订单表 Orders,要转换成分区表,以订单日期 OrderDate 为分区列, 目前含有订单日期为 1996-07-04 ~ 1998-05-06 的数据。可以在 SQL Server 2000 Northwind 数据库中找到 Orders 表,下面是简化了的表结构:create table dbo.Orders( OrderID int not null ,CustomerID varchar(10) not null ,Employe 阅读全文
posted @ 2011-03-10 16:58 .net's 阅读(597) 评论(0) 推荐(0)
摘要:在windows 2008 r2 en中安装sql server 2008 r2 cn出错error:EventType : sql100msi P1 : 10.50.1600.1 P2 : unknown P3 : sqlsupport.msi P4 : 0x2d2816fe P5 : 0x3 P6 : install_sqlsupport-----------I haverun into th... 阅读全文
posted @ 2010-06-04 17:25 .net's 阅读(1165) 评论(0) 推荐(0)
摘要:SP RETURN STATEMENTSSince the SP RETURN statement can’t return tables, character data, decimal numbers, and so on, it is normallyused only to return an int status or error code. This is a good c... 阅读全文
posted @ 2009-10-14 17:17 .net's 阅读(349) 评论(0) 推荐(0)
摘要:BULK INSERT [HumanResources].[Shift] FROM '$(SqlSamplesSourceDataPath)AdventureWorks 2008 OLTP\Shift.csv'WITH ( CHECK_CONSTRAINTS, CODEPAGE='ACP', DATAFILETYPE='char', FIELDTERMINATOR='\t', ROWTERMINA... 阅读全文
posted @ 2009-10-14 09:28 .net's 阅读(393) 评论(0) 推荐(0)
摘要:[代码] 阅读全文
posted @ 2009-07-20 12:41 .net's 阅读(814) 评论(0) 推荐(0)
摘要:[代码] 阅读全文
posted @ 2009-06-29 23:23 .net's 阅读(3267) 评论(0) 推荐(1)
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER PROCEDURE [dbo].[Nop_ProductSearch] @Keywords... 阅读全文
posted @ 2009-04-17 17:16 .net's 阅读(969) 评论(0) 推荐(0)
摘要:sql server中ISNULL与其它不为NULL的字段作字符串连接时,返回的是NULL 如 Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->SELECT NULL + 'abc' 返回结果 Code Code highlight... 阅读全文
posted @ 2009-01-16 16:58 .net's 阅读(412) 评论(0) 推荐(0)
摘要:SQL 注入是一种攻击方式,在这种攻击方式中,恶意代码被插入到字符串中,然后将该字符串传递到 SQL Server 的实例以进行分析和执行。任何构成 SQL 语句的过程都应进行注入漏洞检查,因为 SQL Server 将执行其接收到的所有语法有效的查询。一个有经验的、坚定的攻击者甚至可以操作参数化数据。 SQL 注入的主要形式包括直接将代码插入到与 SQL 命令串联在一起并使其得以执行的用户输入变... 阅读全文
posted @ 2008-12-04 22:08 .net's 阅读(678) 评论(0) 推荐(0)
摘要:数据库的使用过程中由于程序方面的问题有时候会碰到重复数据,重复数据导致了数据库部分设置不能正确设置…… 方法一 declare @max integer,@id integer declare cur_rows cursor local for select 主字段,count(*) from 表名 group by 主字段 having count(*) > 1 open cur... 阅读全文
posted @ 2008-12-04 10:40 .net's 阅读(400) 评论(0) 推荐(0)
摘要:sql server中 Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->--创建表结构跟old_table的新表 select * into new_table from old_table where 1=0; 若想同时拷贝某些数据,则只要... 阅读全文
posted @ 2008-12-04 10:36 .net's 阅读(542) 评论(0) 推荐(0)
摘要:临时表 可以创建本地临时表和全局临时表。本地临时表仅在当前会话中可见,而全局临时表在所有会话中都可见。临时表不能分区。 本地临时表的名称前面有一个数字符号 (#table_name),而全局临时表的名称前面有两个数字符号 (##table_name)。 SQL 语句使用 CREATE TABLE 语句中为 table_name 指定的值引用临时表,例如: 复制代码 CREATE TA... 阅读全文
posted @ 2008-11-29 11:14 .net's 阅读(705) 评论(0) 推荐(0)
摘要:读取作为输入提供的 XML 文本,然后使用 MSXML 分析器 (Msxmlsql.dll) 对其进行分析,并提供分析后的文档供使用。分析后的文档对 XML 文档中的各节点(元素、属性、文本和注释等)的树状表示形式。 sp_xml_preparedocument 返回一个句柄,可用于访问 XML 文档的新创建的内部表示形式。该句柄在会话的持续时间内有效,或者通过执行 sp_xml_removedo... 阅读全文
posted @ 2008-11-28 22:34 .net's 阅读(639) 评论(0) 推荐(0)
摘要:OPENXML 通过 XML 文档提供行集视图。由于 OPENXML 是行集提供程序,因此可在会出现行集提供程序(如表、视图或 OPENROWSET 函数)的 Transact-SQL 语句中使用 OPENXML。 Transact-SQL 语法约定 语法 OPENXML( idoc int [ in] , rowpattern nvarchar [ in ] , [ f... 阅读全文
posted @ 2008-11-28 22:29 .net's 阅读(634) 评论(0) 推荐(0)
摘要:sql中有聚合函数,group by的时候,聚合函数都是取该分组中符合的那个数据。 如下图所示,在asp分组中,ad中最大为v,em中最大为13,都是取该分组中的最大值, 并不是一定是属于同一行。 所以,根据某个字段(如最大值)去取的某一行的数据时,不能有2个以上的聚合函数一起用。 除非,想获得的数据可以不是同一行的。 阅读全文
posted @ 2008-11-25 22:38 .net's 阅读(891) 评论(0) 推荐(0)
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->// 一次执行多条sql语句 string strconn = @"Data Source=.\sqlexpress;Initial Catalog=info;Integr... 阅读全文
posted @ 2008-10-09 20:33 .net's 阅读(836) 评论(0) 推荐(0)
摘要:Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ALTER PROCEDURE dbo.aspnet_Profile_SetProperties @ApplicationName nvarchar(256), ... 阅读全文
posted @ 2008-08-28 20:34 .net's 阅读(800) 评论(0) 推荐(0)