SQL Server联机丛书:存储过程及其创建[6]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 applebbs 的 blog

if exists (select name from sysobjects
      where name = 'proc1' and type = 'p')
   drop procedure proc1
go
-- creating a procedure on a nonexistent table.
use pubs
go
create procedure proc1
as
   select *
   from does_not_exist
go  
-- here is the statement to actually see the text of the procedure.
select o.id, c.text
from sysobjects o inner join syscomments c 
   on o.id = c.id
where o.type = 'p' and o.name = 'proc1'
go
use master
go
if exists (select name from sysobjects
      where name = 'proc2' and type = 'p')
   drop procedure proc2
go
-- creating a procedure that attempts to retrieve information from a
-- nonexistent column in an existing table.
use pubs
go
create procedure proc2
as
   declare @middle_init char(1)
   set @middle_init = null
   select au_id, middle_initial = @middle_init
   from authors
go  
-- here is the statement to actually see the text of the procedure.
select o.id, c.text
from sysobjects o inner join syscomments c 
   on o.id = c.id
where o.type = 'p' and o.name = 'proc2'
转自: http://goaler.xicp.net/showlog.asp?id=515







本文关键:SQL Server联机丛书:存储过程及其创建
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top