zoukankan      html  css  js  c++  java
  • 分页

    --使用master数据库

    use master

    go
    --判断数据库中是否含有Data数据库

    if exists(select name from sys.databases where name='HaHa')drop database HaHa

    go
    --创建Data数据库

    create database HaHa

    go
    --使用Data数据库

    use HaHa

    go
    if object_id('TableOne') is not null

    drop table TableOne

    go
    set nocount on

    go

    create table TableOne(_id varchar(50),_name varchar(50),_sex char(2)constraint Class_id_FK primary key(_id))

    go

    set nocount off

    go
    set nocount on

    go

    insert into TableOne(_id,_name,_sex) values('1476','哈哈','男')

    go

    set nocount off

    go
    select * from TableOne

    go
    if object_id('TableTwo') is not null

    drop table TableTwo

    go
    create table TableTwo([id] varchar(50),[name] varchar(50),[sex] char(2))

    go
    insert into TableTwo select _id,_name,_sex from TableOne

    go
    ----或者--select _id,_name,_sex into TableTwo from TableOne--go
    --要是采用上面的insert into那么第二张表一定要存在不然不能将第一张表中的数据插入第二张表的--要是采用下面的select那么第二张表一定不能存在的,不然会出现错误说表已经存在的
    select * from TableTwo

    go
    if object_id('Exec_') is not nulldrop procedure Exec_

    go
    create procedure Exec_ 

    @startIndex int,

    @endIndex int,

    @count bit

    as

    if(@count=1)select count(0) from TableOne

    else

    begin

    declare @TableTwo table(_newid int identity(1,1),TableOne_id int)

    set rowcount @endIndex

    insert into @TableTwo(TableOne_id) select _id from TableOne order by _id desc

    select * from TableOne,@TableTwo Two where TableOne._id=Two.TableOne_id and Two.TableOne_id between @startIndex and @endIndex order by Two._newidend

  • 相关阅读:
    SQL字符串处理函数大全
    如何在word2007中并排查看对比显示两个文档
    android系统体系结构
    实现html转Xml
    一款很不错的html转xml工具-Html Agility Pack
    HtmlAgilityPack 之 HtmlNode类
    微信公众平台开发入门教程
    Apache Kafka:下一代分布式消息系统
    JAVA线程池的分析和使用
    ZooKeeper系列之八:ZooKeeper的简单操作
  • 原文地址:https://www.cnblogs.com/meroselove/p/1917452.html
Copyright © 2011-2022 走看看