怎么创建存储过程?在哪里创建 ?

来源:百度知道 编辑:UC知道 时间:2024/06/16 20:00:53
怎么创建存储过程?在哪里创建 ?

是什么数据库啊,我给你个SQL SERVER的吧

/*---------------------- 练习二 -------------------------*/

use bbsDB
go
if exists(select * from sysobjects where name='proc_find1')
drop procedure proc_find1
go
create procedure proc_find1
@userName varchar(10)
as
set nocount on
declare @userID varchar(10)
select @userID=UID from bbsUsers where Uname=@userName
if exists(select * from bbsTopic where TuID=@userID)
begin
print @userName+'发表的主帖如下:'
select 发帖时间=convert(varchar(10),Ttime,111),点击率=TclickCount,
主题=Ttopic,内容=Tcontents from bbsTopic where TuID=@userID
end
else
print @userName+'没有发表过主帖。'
if exists(select * from bbsReply where RuID=@userID)
begin
print @userName+'发表的回帖如下:'
select 回帖时间=convert(varchar(10