• 数据库操作(七)存储过程


    //创建存储过程

    alter procedure zmt_firstpro

    @condition nvarchar(1000)

    as

    begin

    --set nocount on

    declare @strsql nvarchar(1000)

    set @strsql = 'select username from TrainStudents '+@condition

    print(@strsql)

    exec(@strsql)

    end

    exec zmt_firstpro  ' where age >8'

    --//创建临时表1

    alter procedure zmt_firstpro

    as

    begin

    set nocount on

    select * into #zmt_student from TrainStudents

    select * from #zmt_student

    drop table #zmt_student

    end

    exec zmt_firstpro

    //创建临时表2

    alter procedure zmt_firstpro

    as

    begin

    set nocount on

    create table #zmt_student(id int)

    insert into #zmt_student

    select id from TrainStudents

    select * from #zmt_student

    drop table #zmt_student

    end

    exec zmt_firstpro

    //创建临时表3

    alter procedure zmt_firstpro

    @condition nvarchar(1000)

    as

    begin

    set nocount on

    declare @strsql nvarchar(1000)

    create table #zmt_student(id int)

    set @strsql = 'insert into #zmt_student'+@condition+' from TrainStudents '

    print(@strsql)

    exec(@strsql)

    select * from #zmt_student

    drop table #zmt_student

    end

    exec zmt_firstpro ' select id'

  • 相关阅读:
    SQL 大数据查询如何进行优化?
    事件和委托的区别
    虚方法(virtual)和抽象方法(abstract)的和接口(interface)的区别
    高并发的秒杀
    C#算法
    口试C#概念
    口试Linq题
    口试大数据及大并发问题
    Windows下MongoDB安装
    MongoDB简单介绍
  • 原文地址:https://www.cnblogs.com/Yida-Tingting/p/4479089.html
Copyright © 2020-2023  润新知