X龙@China .Net 'blog

需要的不仅仅是工作,而是通过努力得来的美好将来。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  SQL

sql server
摘要:/*productid Name Age Email Mobile----------- ----------------------- -----------1 long 88 test@gmail.com 130000000002 lz pivot执行步骤:将行转列,分组确定行数,添加in后面的列,列值是应用聚和函数后的值1. 隐式分组(对左输入中的所有列除FieldValue,FieldID分组,得到所有行)2. 隔离值(为IN子句中的每个列使用case when FieldID=<目标列> then FieldValu... 阅读全文

posted @ 2012-04-17 21:51 X龙 阅读(506) 评论(0) 推荐(0)

摘要:-- =======================================================================================/*Example:EXEC sp_get_InsertSql @dbName='',@tabList='tb1 where id=0,tb2 WHERE id=0,tb3, tb4',@IncludeIdentity=1,@DeleteOldData=0*/-- ============================================================= 阅读全文

posted @ 2012-02-27 14:54 X龙 阅读(1524) 评论(0) 推荐(0)

摘要:一、数字。如何注入?假设我们要实现一个显示新闻的页面,我们可能会随手写下下面的代码:stringid=Request.QueryString["id"];stringsql="select*fromnewswhereColID="+id;如果传递过来的 id是我们想像的 数字(比如168),那么自然不会有什么问题。但是如果传递过来的id是“168 delete from table ”的话,那么sql的值就变成了“select * from table where ColID=168 delete from news”。对于SQL Server来说是支持 阅读全文

posted @ 2012-02-02 10:29 X龙 阅读(238) 评论(0) 推荐(0)

摘要:/* 名称:获取以,分隔ProdMaterialClass的MClassIDHex获取以,分隔的MClassName*/ALTER FUNCTION GetMaterialNameByHexIDs ( @HexIDs VARCHAR(100) )RETURNS NVARCHAR(200) BEGIN /* 如果参数没有值,返回 '' */ IF ( LEN(... 阅读全文

posted @ 2011-10-17 15:02 X龙 阅读(181) 评论(0) 推荐(0)

摘要:Test Your Changes: Different databases handle SQL differently so it's not possible to lay down hard and fast rules that apply in every situation. What you can do, however, is look here for ideas to try and use anexecution profilerto perform timing tests.Check the ExecutionPlan: Most databases pr 阅读全文

posted @ 2011-07-04 17:06 X龙 阅读(244) 评论(0) 推荐(0)

摘要:如果你的数据库里某个字段存了这样的值如下表你要找出所有name包含3的记录,你可以这样写select * from tablename where charindex(','+'3'+',',','+name+',')>0 阅读全文

posted @ 2011-05-19 15:11 X龙 阅读(1429) 评论(0) 推荐(0)

摘要:逻辑查询处理中的各个阶段 本节介绍逻辑查询处理所涉及的各个阶段。我先简要描述一下每个阶段,然后在后面的几节中对它们进行更为详细的介绍,并把它们应用到一个示例查询。当回忆各个阶段的含义和顺序时,你可以将本节作为一个快速参考。 代码清单1-1列出了查询的一般形式,并根据各个子句被逻辑处理的顺序附以步骤序号。 代码清单1-1 逻辑查询处理的步骤序号 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->(8)SELECT (9)DISTINCT (11) 阅读全文

posted @ 2011-03-21 19:45 X龙 阅读(198) 评论(0) 推荐(0)

摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--SQL SERVER 与ACCESS、EXCEL的数据转换熟悉SQL SERVER 2000的数据库管理员都知道,其DTS可以进行数据的导入导出,其实,我们也可以使用Transact-SQL语句进行导入导... 阅读全文

posted @ 2009-12-10 17:11 X龙 阅读(245) 评论(0) 推荐(0)

摘要:[代码] 阅读全文

posted @ 2009-11-23 14:13 X龙 阅读(815) 评论(0) 推荐(0)

摘要:[代码] 阅读全文

posted @ 2009-11-22 11:42 X龙 阅读(270) 评论(0) 推荐(0)

摘要:convert(datetime,convert(varchar(10),@now,120)+' 00:00') 阅读全文

posted @ 2009-10-23 16:56 X龙 阅读(158) 评论(0) 推荐(0)

摘要:数据类型 类型 描 述 bit 整型 bit 数据类型是整型,其值只能是0、1或空值。这种数据类型用于存储只有两种可能值的数据,如Yes 或No、True 或F... 阅读全文

posted @ 2009-09-27 17:09 X龙 阅读(230) 评论(0) 推荐(0)

摘要:[代码]同时也可以直接使用自定义函数.定义好函数后,可使用select * from fn_yourfunction进行查询. 阅读全文

posted @ 2009-07-02 10:28 X龙 阅读(705) 评论(0) 推荐(0)

摘要:附加的连接字符串为:老是不记得单词怎么写,今天记下Data Source=.;AttachDbFilename=E:\db\mydb.mdf;Persist Security Info=True;User ID=sa;Password=secret;Connect Timeout=30;User Instance=False 阅读全文

posted @ 2009-05-06 15:46 X龙 阅读(209) 评论(0) 推荐(0)

摘要:Code Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->Create procedure [dbo].[P_Page_Data] ( @tableName varchar(80), @currentPageIndex int=1 , @pa... 阅读全文

posted @ 2009-05-03 18:27 X龙 阅读(185) 评论(0) 推荐(0)

摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->create proc sp_UserAuthen @name nvarchar(50), @password nvarchar(50)as declare @n nv... 阅读全文

posted @ 2009-04-29 13:13 X龙 阅读(381) 评论(0) 推荐(0)

摘要:1.搜索出所有表名,构造为一条SQL语句 declare @trun_name varchar(8000)set @trun_name=''select @trun_name=@trun_name + 'truncate table ' + [name] + ' ' from sysobjects where xtype='U' and status > 0exec (@trun_name) 该方... 阅读全文

posted @ 2009-04-05 10:04 X龙 阅读(840) 评论(0) 推荐(0)

摘要:T-SQL补遗索引表 通配符 _ 匹配任一字符,例如,J_y匹配Joy与Jay % 匹配任意个字符,例如,%wind匹配Norwind与Southwind;%fire%匹配starfire、firestarter与fireman [] 匹配方括号中任一字符。例如,[sm]ay匹配say与may [^ ] 匹配不在方括号中的任... 阅读全文

posted @ 2009-02-13 09:31 X龙 阅读(234) 评论(0) 推荐(0)

摘要:1。首先执行from ,就是把多个表合并 2。执行where,过滤一些数据 3。group by 分组,再根据having 过滤一些数据。 4。计算select后面的分组函数 5。order by 排序 6。根据select,把要显示的字段现实出来 阅读全文

posted @ 2009-02-13 09:24 X龙 阅读(263) 评论(0) 推荐(0)

摘要:dbcc checkident(cusTable,reseed,0) cusTable:表名. 更改列名:sp_rename 'table.columnname' ,'newcolumnname' ,'column' 阅读全文

posted @ 2009-02-10 17:39 X龙 阅读(612) 评论(0) 推荐(0)

点击这里给我发消息http://wp.qq.com/index.html