• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
爱白菜的小昆虫
博客园    首页    新随笔    联系   管理    订阅  订阅

随笔分类 -  SQLserver学习

1 2 下一页
SQL Sever 身份验证 sa用户设置

摘要:1.用windows身份验证登陆数据库找到sa用户 2.鼠标右键sa->属性->常规,设置密码。 3.选择状态->登陆选择已启用 4.选中当前数据库 鼠标右键->属性 5.选择安全性->SQL Server和Windows 身份验证。。。 如果sa用户登陆出现 错误:18456 可能第5步没有做。 阅读全文
posted @ 2016-04-18 22:30 爱白菜的小昆虫 阅读(714) 评论(0) 推荐(1)
SQL server 表之间的关系生成图

摘要:选择数据库名->数据库关系鼠标右键->新建数据库关系图按着ctrl选择要添加的表点击添加 阅读全文
posted @ 2015-07-02 16:26 爱白菜的小昆虫 阅读(8213) 评论(0) 推荐(1)
SQL 过滤 having

摘要:select * from emp--having 对分组之后使用--输出部门号 和 部门的平均工资 并且 平均工资 > 2000select deptno, avg(sal) as "平均工资" from emp group by deptno having avg(sal)... 阅读全文
posted @ 2015-05-15 11:39 爱白菜的小昆虫 阅读(190) 评论(0) 推荐(0)
SQL 分组查询 group by

摘要:select * from emp--deptno 为部门号--输出每个部门的编号 和 该部门的平均工资--group by deptno; 通过deptno分组select deptno, avg(sal) as "部门平均工资" from emp group by deptno; 阅读全文
posted @ 2015-05-15 11:22 爱白菜的小昆虫 阅读(236) 评论(0) 推荐(0)
SQL 自动增长 identity

摘要:create table Users(id int identity(10000,1),--id 从10000开始,增加长度为1name nvarchar(10),);--执行三次这个语句insert into Users values('小昆虫'); 阅读全文
posted @ 2015-05-05 11:29 爱白菜的小昆虫 阅读(223) 评论(0) 推荐(0)
SQL 基本的函数

摘要:select * from emp;select max(sal) from emp;--sal中最大值select min(sal) from emp;--sal中最小值select avg(sal) from emp;--sal的平均值select count(sal) from emp;--统... 阅读全文
posted @ 2015-05-02 17:58 爱白菜的小昆虫 阅读(239) 评论(0) 推荐(0)
SQL like 模糊查询

摘要:select * from emp;--查询ename中含有A的字母select * from emp where ename like '%A%';--查询ename中第一个字母是A的输出select * from emp where ename like 'A%';--查询ename中末尾字母为... 阅读全文
posted @ 2015-05-01 13:15 爱白菜的小昆虫 阅读(2428) 评论(0) 推荐(0)
SQL order by 两个字段排序

摘要:select * from emp;--先按照sal排序,如果sal相同,就按照deptno排序select * from emp order by sal, deptno;--先按照deptno排序,如果deptno相同,就按照sal排序select * from emp order by dep... 阅读全文
posted @ 2015-04-25 23:35 爱白菜的小昆虫 阅读(2008) 评论(0) 推荐(0)
SQL isnull函数

摘要:select * from emp;--就算年收入:sal*12+comm,sal为月工资,comm为年薪select ename, sal*12+isnull(comm, 0) from emp;--为什么要使用isnull函数,因为null值不能参加运算select ename, sal*12+... 阅读全文
posted @ 2015-04-24 12:24 爱白菜的小昆虫 阅读(285) 评论(0) 推荐(0)
SQL null值 查询null

摘要:select * from emp;--查询comm为null的员工信息select * from emp where comm is null;--查询comm不为null的员工信息select * from emp where comm is not null; 阅读全文
posted @ 2015-04-24 12:12 爱白菜的小昆虫 阅读(295) 评论(0) 推荐(0)
SQL top order between 一起使用

摘要:select * from emp;--输出工资在[1500,3000]范围之内的工资最高的前5个员工信息select top 5 * from emp where sal between 1500 and 3000 order by sal desc; 阅读全文
posted @ 2015-04-24 11:41 爱白菜的小昆虫 阅读(418) 评论(0) 推荐(0)
SQL order 排序

摘要:select * from emp;--按照工资升序排序select * from emp order by sal;--按照工资降序排序select * from emp order by sal desc; 阅读全文
posted @ 2015-04-24 11:34 爱白菜的小昆虫 阅读(226) 评论(0) 推荐(0)
SQL top查询

摘要:select *from emp;--查询表前5行 员工信息select top 5 * from emp;--查询表前15%行的员工信息select top 15 percent * from emp; 阅读全文
posted @ 2015-04-24 00:14 爱白菜的小昆虫 阅读(352) 评论(0) 推荐(0)
SQL in查询

摘要:--sal为员工工资select * from emp;--查询工资等于1500或3000或5000的用户信息select * from emp where sal in (1500, 3000, 5000);select * from emp where sal = 1500 or sal = 3... 阅读全文
posted @ 2015-04-23 23:23 爱白菜的小昆虫 阅读(820) 评论(0) 推荐(0)
SQL between查询 范围查询

摘要:--sal为员工工资select * from emp;--查询工资在[1500,3000]范围的员工信息select * from emp where sal >= 1500 and sal <= 3000;select * from emp where sal between 1500 and ... 阅读全文
posted @ 2015-04-23 23:08 爱白菜的小昆虫 阅读(4323) 评论(0) 推荐(0)
SQL 2008 数据库只读 修改

摘要:先对数据库分离 数据库鼠标右键->任务->分离将UsersDB.mdf UsersDB_log.LDF文件 属性->安全->编辑两个文件的都要更改权限然后在附加数据库 数据库鼠标右键->附加 选择文件路径 阅读全文
posted @ 2015-04-23 17:07 爱白菜的小昆虫 阅读(689) 评论(0) 推荐(0)
SQL distinct

摘要:select *from emp;select deptno from emp;select distinct deptno from emp;--过滤deptno 重复的数据distinct 对null也会过滤select distinct comm, deptno from emp;--过滤co... 阅读全文
posted @ 2015-04-22 14:15 爱白菜的小昆虫 阅读(201) 评论(0) 推荐(0)
SQL 简单查询语句 select

摘要:select *from emp;//查询emp表内容select ename, job from emp;//从emp表中查询ename和job列select ename, sal from emp;//在表emp中查询ename和sal列select ename, sal*12 from emp... 阅读全文
posted @ 2015-04-22 13:37 爱白菜的小昆虫 阅读(536) 评论(0) 推荐(0)
SQL 启动服务方法

摘要:(1)windows开始菜单->Microsoft SQL Server 2012->配置工具->配置管理器查看服务(2)win7 将鼠标移到菜单栏->鼠标右键->任务管理器选择服务这是window自带服务在右边任意选中一个,在键盘上输入sq(3)计算机鼠标右键->管理 阅读全文
posted @ 2015-04-21 09:31 爱白菜的小昆虫 阅读(362) 评论(0) 推荐(0)
SQL 2012 连接失败

摘要:未打开服务打开服务连接成功 阅读全文
posted @ 2015-04-21 09:13 爱白菜的小昆虫 阅读(220) 评论(0) 推荐(0)

1 2 下一页
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3