zoukankan      html  css  js  c++  java
  • SQL语句

    --创建数据库

    create database ShoppingManage
    on
    (

    --数据库文件名称
    name = 'ShoppingManage.mdf',

    --数据库路径(包含数据库文件名称)
    filename = 'E:资料DataShoppingManage.mdf'
    )

    --删除数据库

    drop database 数据库名称

    --例如drop database ShoppingManage

    --创建一个用户表
    create table [User]
    (
    UserId int primary key identity(1,1), --用户ID
    UserName nvarchar(50) not null, --用户账号
    UserPwd nvarchar(30) , --用户密码
    UserCreateTime datetime default(getdate()),--用户创建时间
    UserLastLoginTime datetime, --最后登录时间
    UserLoginCount int default(0) --登录次数
    )

    --添加数据
    insert into [User](UserName,UserPwd) values('王亦欣','123456')

    --删除表不会留下痕迹
    truncate table 表名 --例如truncate table [User]

    --删除表会留下痕迹 

    drop table 表名 --例如drop table [User]

    --创建一个可以实现分页的存储过程

    create proc SP_Pager

    --从第几条数据开始查询
    @startIndex int,

    --从第几条数据结束查询
    @endIndex int
    as
    select * from (select *,ROW_NUMBER() over(order by Id) as rid from Products ) temp where rid>=@startIndex and rid<=@endIndex ;

    --执行存储过程

    exec SP_Pager startIndex ,endIndex 例如exec SP_Pager 1,20是查询Products表中按ID排序之后的第一条数据到第20条的数据

    --执行有参有返回值的存储过程

    declare @number nvarchar(4000);
    exec 存储过程名称 输入参数,输入参数,@number(输出参数);

    select @number

  • 相关阅读:
    推荐影视
    《算法设计》一、引言:某些典型的问题
    使用google地图API
    Python导入不同文件夹下模块
    Pycharm之远程编程
    linux之scp
    Photoshop脚本之jpg转换成eps
    win7重新安装win7
    查看修改swap空间大小
    用 EasyBCD 在 Win7/8 中硬盘安装 Ubuntu
  • 原文地址:https://www.cnblogs.com/zhudezhiwansui/p/6373334.html
Copyright © 2011-2022 走看看