ylbtech-SQL Server-Basic:SQL Server-数据库查询语句基本查询

SQL Server 数据库查询语句基本查询。

1,数据库查询语句基本查询
 
数据库 SQL Server Oracle
基本语句    
select

select * from titles

select title_id,title,price,pub_id from titles

select * from title where title_id=9834

select * from title order by price

select * from authirs order by a_lname,a_fname

select type,count(title_id)as 每种类型数量 from title group by type

注意:where 在前 order by 其次 group by 最后

同左←
delete delete into title where title_id=9874 同左←
update update title set title=title1,price=price1 where title_id=9874 同左←
insert

insert titles(,,,,) values(,,,,)

insert titles(title,price) values('thanks to java',23.5)

同左←
建视图    
  create view view_name
as

sql语句
 
建存储过程    
  create procdure proc_name
as
sql语句
 
有参数(只有入参) create proc ups_shj
@pub_id varchar(20)
as
select * from titles where pub_id=@pub_id;
 
有参数(入参,出参output)

create proc ups_shj1
@title varchar(200),
@ytd_sales int output
as
select @ytd_sales=ytd_sales from titles where title=@title;

--执行存储过程,查找书籍'Sushi, Anyone?'
go
declare @sales int
exec ups_shj1 'Sushi, Anyone?',@ytd_sales=@sales output
select @sales

 
     

作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

T-SQL:SQL Server-数据库查询语句基本查询的更多相关文章

  1. SQL server 数据库基础语句 子查询 基础函数

    上一章 说了下   子查询的意义是 把一条查询语句当做值来使用 select *from car   //查询汽车的信息 假设我知道一个汽车的编号是 c021 但是我要查询 比这个汽车价格高的汽车信息 ...

  2. SQL查询语句,怎样查询重复数据

    SQL查询语句,怎样查询重复数据 2012-02-22 14:50神奇的马骁勇 | 浏览 0 次 有表A, 中有字段id, name, memo现在有很多id重复的数据,怎么把这些重复的都查出来?gr ...

  3. SQL server 数据库基础语句 查询语句

    这一章要学习查询语句 我看car这一数据 我们就开始打上 select  *from car 条件修改 update 表名 set 列名1=值1 where 列名2=值2   //当列名2=值2时   ...

  4. SQL Server数据库阻塞,死锁查询

    sql 查询卡顿数据库 SELECT SPID=p.spid, DBName = convert(CHAR(20),d.name), ProgramName = program_name, Login ...

  5. access建立sql查询语句运行查询语句

    1.打开一个Access数据库文件 2.点击“创建”标签中的“查询设计”,会弹出一个“显示表”的对话框,点击“关闭”将其关闭 3.这时会有一个名为“查询*”的窗口,还不能输入SQL语句 4.点击左上角 ...

  6. 数据库---T-SQL语句:查询语句(二)

    >查询: 一.查询所有数据: select * from Info    ---查询所有数据(行) select Name from Info  ---查询特定列(Name列) select N ...

  7. mysql查询语句select-子查询

    1 子查询定义 在一个表表达中可以调用另一个表表达式,这个被调用的表表达式叫做子查询(subquery),我么也称作子选择(subselect)或内嵌选择(inner select).子查询的结果传递 ...

  8. SQL server数据库表碎片比例查询语句

    For rebuilding index, here is also a script to figure out the fragmentation and decide whether rebui ...

  9. SQL server 数据库 操作及简单查询

    使用SQL Sever语言进行数据库的操作 常用关键字identity 自增长primary key 主键unique 唯一键not null 非空references 外键(引用) 在使用查询操作数 ...

随机推荐

  1. 【重走Android之路】【番外篇】有关于null的一些知识点

    [重走Android之路][番外篇]有关于null的一些知识点   1.首先,到底什么是null? null是Java中的一个关键字,用于表示一个空对象引用,但其本身并不是任何类型也不是属于任何对象. ...

  2. jQuery deferred when用法

    一.什么是deferred对象? 开发网站的过程中,我们经常遇到某些耗时很长的javascript操作.其中,既有异步的操作(比如ajax读取服务器数据),也有同步的操作(比如遍历一个大型数组),它们 ...

  3. SPOJ 227 Ordering the Soldiers 线段树 / 树状数组

    题意:设原数组为a[i],pos[i]代表第 i 个位置之前有多少个数比a[i]大,求原数组a[i]. 这个题意是看了别人的题解才明白,我自己没读出来…… 方法:假设我们从左往右放,因为后面的数还有可 ...

  4. 【USACO】Transformations

    A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into ...

  5. excel跨表数据链接

    按=,然后选择第二个页签下某个数据. 去掉$号,就可以下拉数据

  6. ZOJ Problem Set - 3861 Valid Pattern Lock(dfs)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3861 这道题当时没做出来,后来经过队友提醒才做出来. 3*3的九宫格,给你 ...

  7. Android模拟器分辨率介绍

    转自: http://www.cnblogs.com/xrtd/p/3746935.html 本人喜欢用  HVGA(320x480) Skins:HVGA.HVGA-L.HVGA-P.QVGA-L. ...

  8. 第三方登录(2)Android客户瑞上第三方登录百度教程

    1,在 http://developer.baidu.com/  注册成开发者 不注册看不到开发相关的链接地址.点自己的用户名,在弹出菜单显示有 <用户中心> ,没有就是没注册. 2,找到 ...

  9. Winform——计算器进制转换

    namespace 进制转换2._0 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } p ...

  10. 用FireMonkey写QQ皮肤

    这是运行在Windows平台的效果,同样不需要改一行代码就可以运行在Mac Os,并且效果完全相同: 用FireMonkey做界面速度非常快,其提供的Effect ,Filter,Animation等 ...