易截截图软件、单文件、免安装、纯绿色、仅160KB

Sql基本语句的学习

--查询每个人订饭的次数
select  username as 姓名, count(*) as 次数 from orderitems  group by UserName having count(*)=1
order by 姓名 desc
select distinct username as 未注册姓名 from orderitems
where username not in (select [Name] from Person)
select distinct username as 已注册姓名 from orderitems where username
in (select [Name] from Person)
--索引为31-40的数据
select top 10 * from orderitems where ID not in (select top 30 ID from orderitems)
--复制数据
insert into  distinctselect(UserName,State,OrderTime) select UserName,State,OrderTime from orderitems
--去除所有重复的记录(完全重复)
select distinct UserName ,ID, State,OrderTime into #Table1 from [distinctselect]
delete from [distinctselect]
insert into [distinctselect](UserName,State,OrderTime) select UserName,State,OrderTime from #Table1
drop table #Table1
--删除某列重复的记录
delete   t  
  from   [distinctselect]   t  
  where   exists   (  
  select   1   from   [distinctselect]  where   username=t.username   and   id<t.id) 
select * from [distinctselect] order by username
delete from [distinctselect]


相关文档:

讲解SQL Server数据库被挂马的解决方案

讲解SQL Server数据库被挂马的解决方案
http://www.cnhacker.com/Security/Plan/200808/t20080822_6383.html
案例:一个网站遭遇入侵,破坏相当严重,SQL数据库被挂马,所有的表里面大部分字段都被多次重复插入挂马代码,查看日志,还好没有涉及到服务器的安全,只是数据库那里出现了很多异常警告而已,网站确实存在漏洞 ......

SQL存储过程基础语法

一.注释
-- 单行注释,从这到本行结束为注释sql 语法,类似C++,c#中//
/* … */ 多行注释,类似C++,C#中/* … */
二.变量(int, smallint, tinyint, decimal,float,real, money ,smallmoneysql 语法, text ,image, char, varchar。。。。。。)
语法:
DECLARE
{
{@local_variable data_t ......

Sql Server 基础

软件 : Sql Server 2005
 
    这里并不是SQL语法大全,以下是常用的语句,对(数据库、表、字段、数据)的增删改查,如果需要详细全面的Transact-SQL语句,可以查Sql Server联机丛书,那里是最全的资料,一般安装Sql Server都会默认安装。
打开Sql Server联机丛书
开始 à 程序 à&n ......

SQL数据库加密方法

转贴自teched讲师:  牛可 
基本概念:
第一层 服务主密钥
备份服务主密钥
backup service master key to file='c:\smk.bak'
encryption by password='P@ssw0rd'
 
restore service master key from file='c:\smk.bak'
decryption by password='P@ssw0rd'
 
第二层 数据库主密钥
1)必须先在 ......

SQL基础题

Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
from SC wher ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号