首页 > 数据库技术 > 详细

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

时间:2015-05-05 15:46:47      阅读:101      评论:0      收藏:0      [点我收藏+]

//创建存储过程

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‘

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

原文:http://www.cnblogs.com/Yida-Tingting/p/4479089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!