use UN_VISA
go
--创建存储过程
create procedure pro_test
@yc int,@lyq int,@nsx int output
as
if (@yc > @lyq)
print 'yc>lyq'
else
print 'yc<lyq'
select @yc=count(*) from Employee
if (@yc <> 0 and @yc >0)
set @nsx = @yc
print @nsx
go
create procedure pro_test2
@yc int
as
select @yc=count(*) from Authorize
print @yc
go
--执行指定存储过程
exec pro_test 4,3,4
exec pro_test2 1
--查看指定存储过程创建文本
exec sp_helptext pro_test
--查看当前数据库下的所有存储过程
exec sp_stored_procedures
--OBJECTPROPERTY : 返回当前数据库中对象的有关信息
--OBJECT_ID:返回数据库对象标识号。
--N是显式的将非unicode字符转成unicode字符,它来自 SQL-92 标准中的 National(Unicode)数据类型
select * from dbo.sysobjects where OBJECTPROPERTY(id, N'IsProcedure') = 1 order by name desc
select * from dbo.sysobjects where id = Object_Id(N'pro_test') and OBJECTPROPERTY(id, N'IsProcedure') = 1
--销毁指定存储过程
drop procedure pro_test,pro_test2
存储过程小记
最新推荐文章于 2025-05-07 19:46:16 发布