SQL经典短小代码收集
--SQL Server:
Select TOP N * from TABLE Order By NewID()
--Access:
Select TOP N * from TABLE Order By Rnd(ID)
Rnd(ID) 其中的ID是自动编号字段,可以利用其他任何数值来完成,比如用姓名字段(UserName)
Select TOP N * from TABLE Order BY Rnd(Len(UserName))
--MySql:
Select * from TABLE Order By Rand() Limit 10
--开头到N条记录
Select Top N * from 表
--N到M条记录(要有主索引ID)
Select Top M-N * from 表Where ID in (Select Top M ID from 表) Order by ID Desc
--选择10从到15的记录
select top 5 * from (select top 15 * from table order by id asc) table_别名order by id desc
--N到结尾记录
Select Top N * from 表Order by ID Desc
--显示最后5条记录,但是显示的顺序必须为5,6,7,8,9,10,而不是10,9,8,7,6,5 如下解决方法:
select top 5 from test where id in(select top 5 from test order by id desc) order by id asc
--通过这个问题也能总结出4-10条,5-100条这种限定一定范围内的sql语句的写法:
select top <末端ID-顶端ID+1> * from <表名> where ID not in(select top <顶端ID-1>) ID from <表名>)
--例如:4-10条就应该写成
select top 10-4+1 * from test where id not in(select top 4-1 id from test)
上一篇: select top 1 * from [news_table] where [新闻标识列]<当前id号 where ......
下一篇: select top 1 * from [news_table] where [新闻标识列]>当前id号 where ...... order by [新闻标识列] desc --两条记录完全相同,如何删除其中一条
set rowcount=1
delete from thetablename where id=@duplicate_id--@duplicate_id为重复值的id
--模糊查询
select * &nbs
相关文档:
今天从数据库中查询出xml,同时添加一个根节点
做了如下测试:
create table TestXmlQuery(
ID int identity(1,1) not null,
Name varchar(10)
)
go
insert into [TestXmlQuery] (Name) values('测试1')
insert into [TestXmlQuery] (Name) values('测试2')
insert into [TestXmlQuery] (Name) values('测试3')
......
首先写一个SQL注入过滤的类:
public class SqlFilter
{
#region SQL注入式攻击代码分析
/// <summary>
/// 处理用户提交的请求
/// </summary>
public void StartProcessRequest()
{
string getkeys = "";
s ......
更新:新的东西从最新的更新将是红色的。
This list will grow as I find new tools.这份名单将成长为我找到新的工具。 So if you know of some not on this list do post them in the comments.所以,如果你知道一些不在此名单中的意见后做他们。
SQL Server Management Studio Add-in's SQL Server管理工作室外接的
......
SELECT DISTINCT '['+user_name(b.uid)+'].['+b.name+']' AS 对象名,b.type AS 类型
from sysdepends a,sysobjects b
WHERE b.id=a.depid
AND a.id=OBJECT_ID('过程名');
EXEC SP_DEPENDS '过程名';
......
在Essbase中使用MDX只能用于查询,尚不能来操作Cube(MS SSAS中可以使用MDX来操作Cube的),所以这里只学习MDX的Select语句。
在学习的过程中,我觉得最有难度的地方有两个。
一是,对OLAP多维的理解。如同学习SQL一样,SQL作用的对象是表,表的结构都是二维的,标识行列即可;但是MDX作用的对象是多维数据库,那 ......