当前位置:首页 » 存储配置 » 创建存储

创建存储

发布时间: 2022-02-11 04:20:20

㈠ 如何创建sql存储过程

步骤如下:

  1. 在对象资源管理器中,连接到某个数据库引擎实例,再展开该实例。

  2. 展开“数据库”、sql server存储过程所属的数据库以及“可编程性”。

  3. 右键单击“存储过程”,再单击“新建存储过程”。

  4. 在“查询”菜单上,单击“指定模板参数的值”。

  5. 在“指定模板参数的值”对话框中,“值”列包含参数的建议值。接受这些值或将其替换为新值,再单击“确定”。

  6. 在查询编辑器中,使用过程语句替换 SELECT 语句。

  7. 若要测试语法,请在“查询”菜单上,单击“分析”。

  8. 若要创建sql server存储过程,请在“查询”菜单上,单击“执行”。

  9. 若要保存脚本,请在“文件”菜单上,单击“保存”。接受该文件名或将其替换为新的名称,再单击“保存”。

㈡ 如何创建存储过程

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

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

use bbsDB
go
if exists(select * from sysobjects where name='proc_find1')
drop procere proc_find1
go
create procere 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),Rtime,111),点击率=RclickCount,
回帖内容=Rcontents from bbsReply where RuID=@userID
end
else
print @userName+'没有发表过回帖。'
go

exec proc_find1 '可卡因'

/*---------------------- 练习三 -------------------------*/

if exists(select * from sysobjects where name='proc_find2')
drop procere proc_find2
go
create procere proc_find2
@userName varchar(10),
@sumTopic int output,
@sumReply int output
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
select @sumTopic=count(*) from bbsTopic where TuID=@userID
print @userName+'发表的主帖如下:'
select 发帖时间=convert(varchar(10),Ttime,111),点击率=TclickCount,
主题=Ttopic,内容=Tcontents from bbsTopic where TuID=@userID
end
else
begin
set @sumTopic=0
print @userName+'没有发表过主帖。'
end
if exists(select * from bbsReply where RuID=@userID)
begin
select @sumReply=count(*) from bbsReply where RuID=@userID
print @userName+'发表的回帖如下:'
select 回帖时间=convert(varchar(10),Rtime,111),点击率=RclickCount,
回帖内容=Rcontents from bbsReply where RuID=@userID
end
else
begin
set @sumReply=0
print @userName+'没有发表过回帖。'
end
go

declare @sum1 int, @sum2 int
exec proc_find2 '可卡因',@sum1 output,@sum2 output
if @sum1>@sum2
print '小弟发帖比回帖多,看来比较喜欢标新立异!'
else
print '小弟回帖比发帖多,看来比较关心民众疾苦!'
print '总帖数:'+convert(varchar(5), @sum1+@sum2)
go

/*---------------------- 练习题一 -------------------------*/

if exists(select * from sysobjects where name='proc_find3')
drop procere proc_find3
go
create procere proc_find3
@userName varchar(10),
@sumTopic int output,
@sumReply int output,
@secName varchar(15)=''
as
set nocount on
declare @userID varchar(10)
select @userID=UID from bbsUsers where Uname=@userName
--版块名称为空
if (@secName='')
begin
if exists(select * from bbsTopic where TuID=@userID)
begin
select @sumTopic=count(*) from bbsTopic where TuID=@userID
print @userName+'发表的主帖数为:'+convert(varchar(5),@sumTopic)+' , 内容如下:'
select 发帖时间=convert(varchar(10),Ttime,111),点击率=TclickCount,
主题=Ttopic,内容=Tcontents from bbsTopic where TuID=@userID
end
else
begin
set @sumTopic=0
print @userName+'没有发表过主帖。'
end
if exists(select * from bbsReply where RuID=@userID)
begin
select @sumReply=count(*) from bbsReply where RuID=@userID
print @userName+'发表的回帖数量为:'+convert(varchar(5),@sumReply)+' , 内容如下:'
select 回帖时间=convert(varchar(10),Rtime,111),点击率=RclickCount,
回帖内容=Rcontents from bbsReply where RuID=@userID
end
else
begin
set @sumReply=0
print @userName+'没有发表过回帖。'
end
end
--版块名称不为空
else
begin
if exists(select * from bbsTopic where TuID=@userID)
begin
select @sumTopic=count(*) from bbsTopic where TuID=@userID
and TsID=(select SID from bbsSection where Sname like @secName)
print @userName+'曾在 '+@secName+' 版块发表的主帖数量为:'+convert(varchar(5),@sumTopic)+' , 内容如下:'
select 发帖时间=convert(varchar(10),Ttime,111),点击率=TclickCount,
版块名称=@secName,主题=Ttopic,内容=Tcontents from bbsTopic where TuID=@userID
end
else
begin
set @sumTopic=0
print @userName+'没有发表过主帖。'
end
if exists(select * from bbsReply where RuID=@userID)
begin
select @sumReply=count(*) from bbsReply where RuID=@userID
and RsID=(select SID from bbsSection where Sname like @secName)
print @userName+'曾在 '+@secName+' 版块发表的回帖数量为:'+convert(varchar(5),@sumReply)+' , 内容如下:'
select 回帖时间=convert(varchar(10),Rtime,111),点击率=RclickCount,
版块名称=@secName,回帖内容=Rcontents from bbsReply where RuID=@userID
end
else
begin
set @sumReply=0
print @userName+'没有发表过回帖。'
end
end
go

declare @sum1 int, @sum2 int
exec proc_find3 '可卡因',@sum1 output,@sum2 output,'.NET技术'
if @sum1>@sum2
print '小弟发帖比回帖多,看来比较喜欢标新立异!'
else
print '小弟回帖比发帖多,看来比较关心民众疾苦!'
print '总帖数:'+convert(varchar(5), @sum1+@sum2)
go

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

/*---------------------- 作业题 -------------------------*/

use bbsDB
go
if exists(select * from sysobjects where name='proc_delive')
drop procere proc_delive
go
create procere proc_delive
@userName varchar(10),
@sectionName varchar(20),
@topic varchar(20),
@contents varchar(20),
@face int
as
set nocount on
declare @userID varchar(10),@sectionID varchar(10)
select @userID=UID from bbsUsers where Uname=@userName
select @sectionID=SID from bbsSection where Sname like @sectionName

print @userName+'发帖前的状态如下:'
select * from bbsUsers where UID=@userID

insert into bbsTopic(TsID,TuID,Ttopic,Tcontents,Tface)
values(@sectionID,@userID,@topic,@contents,@face)

print @userName+'发帖如下:'
select * from bbsTopic where TID=@@identity

update bbsSection set StopicCount=StopicCount+1 where SID=@sectionID
if not exists(select * from bbsTopic where Ttopic like @topic and TuID=@userID)
update bbsUsers set Upoint=Upoint+100 where UID=@userID
else
update bbsUsers set Upoint=Upoint+50 where UID=@userID

update bbsUsers set Uclass=case
when Upoint <500 then 1
when Upoint between 500 and 1000 then 2
when Upoint between 1001 and 2000 then 3
when Upoint between 2001 and 4000 then 4
when Upoint between 4001 and 5000 then 5
else 6
end
where UID=@userID

print @userName+'发帖后的状态如下:'
select * from bbsUsers where UID=@userID
go

exec proc_delive '心酸果冻','.NET技术','.NET问题','请问如何使用……',3
go

㈢ 创建存储过程

大哥,不是点击保存!是要点击执行才行!红色!

㈣ 怎样创建自己的存储空间

不大明白你说的是什么意思.是不是想要一个网络硬盘之类的存储空间?如是给我发信息.

㈤ 怎么创建存储过程

有存储过程的向导
打开sql的企业管理器,定位到你要建立存储过程的数据库.在工具菜单里单击”向导”,打开”选择向导”对话框.在注册服务向导中单击”数据库”
在打开的列表中有”创建存储过程的向导”
你只要按提示操作就可以了

㈥ 如何创建存储过程

create proc proc_s2
(@SNO char(5)='S1')
as
begin
select QTY

from SPJ

where SNO=@SNO

end
GO
proc_s2 @SNO='S2'

㈦ sql的创建存储语句怎么写啊

--[p2]
create proc p2 @blh char(6),@odate datetime
as
select 病历号,入院时间 from 诊疗情况
where 病历号=@blh and 入院时间=@odate
go
--2.
create proc 存储过程名1 @blh char(6),@outdate datetime
as
update 诊疗情况 set 出院时间=getdate() where 病历号=@blh
exec p2 @blh,@outdate
commit
go

--修改病历号为A01101 ,入院时间为‘2012-5-1’的病人出院时间
exec 存储过程名1 'A01101','2012-5-1'
go

--[p3]:
create proc p3 @dname varchar(10),@avg_age int output
as
select @avg_age=avg(病人.年龄)
from 病人,诊疗情况,医生
where 医生.医生号=诊疗情况.医生号
and 诊疗情况.病历号=病人.病历号
and 医生.医生姓名=@dname
go
--3.
create proc 存储过程名2 @dname varchar(10)
as
declare @avgage int
exec p3 @dname,@avg_age=@avgage output
select 病人.病人姓名,病人.病人年龄
from 病人,诊疗情况,医生
where 医生.医生号=诊疗情况.医生号
and 诊疗情况.病历号=病人.病历号
and 医生.医生姓名=@dname
and 病人.病人年龄>@avgage
go

㈧ sql怎样新建存储过程

一:创建没有参数的存储过程:

CREATE PROCEDURE select_all

AS

BEGIN

SELECT * from T_login1

GO

二:创建带参数的存储过程:

CREATE PROCEDURE select_name

@id uniqueidentifier

AS

BEGIN

SELECT * from T_login1 where PSN0001A=@id

GO

(8)创建存储扩展阅读

创建存储过程的注意事项:

1、保持事务简短,事务越短,越不可能造成阻塞。

2、在事务中尽量避免使用循环while和游标,以及避免采用访问大量行的语句。

3、在启动事务前完成所有的计算和查询等操作,避免同一事务中交错读取和更新。可以使用表变量预先存储数据。即存储过程中查询与更新使用两个事务实现。

4、超时会让事务不执行回滚,超时后如果客户端关闭连接sqlserver自动回滚事务。如果不关闭,将造成数据丢失,而其他事务将在这个未关闭的连接上执行,造成资源锁定,甚至服务器停止响应。

㈨ 如何创建存储帐户

登录到管理门户。

依次单击 “新建”、“数据服务”、“存储”和“快速创建”。

新建存储帐户

在“URL”中,输入要在存储帐户 URL 中使用的子域名称。若要访问存储中的对象,请将该对象的位置附加到终结点。

在“区域/地缘组”中,为存储选择区域或地缘组。如果您希望存储服务与您所使用的其他 Windows Azure 服务位于同一数据中心,请选择一个地缘组而不是区域。这可以提高性能,且不会对数据传出收费。

注意
若要创建地缘组,请打开管理门户的“网络”区域,单击“地缘组”,然后单击“创建新的地缘组”或“创建”。您也可以使用 Windows Azure 服务管理 API 创建和管理地缘组。有关详细信息,请参阅针对地缘组的操作。

在“订阅”中,输入要使用存储帐户的 Windows Azure 订阅。您可以为一个订阅创建多达 5 个存储帐户。

在“复制”中,选择对您的存储帐户所期望的复制级别。

默认情况下,复制设置为 Geo-Rendant.。使用地域冗余复制,在主要位置中发生重大灾难时,您的存储帐户以及帐户中的所有数据都将故障转移到辅助位置。Windows Azure 在同一区域中分配辅助位置,并且不能更改。在进行故障转移后,辅助位置将成为存储帐户的主要位置,并且会将数据复制到新的辅助位置。

如果不希望使用地域冗余复制,或者如果贵组织的策略不允许使用它,则可以将“复制”设置为“本地冗余”。此时将使用以优惠价提供的本地冗余存储。请注意,如果您关闭地域冗余复制,但稍后决定重新打开它,那么在您将现有数据复制到辅助位置时,将向您收取一次性费用。

第三个复制选项“读取访问地域冗余”允许对辅助位置中的已复制数据进行只读访问。通过读取访问地域冗余复制,您可以在一个位置变得不可用时从主位置或辅助位置访问您的数据。

有关存储帐户复制的定价信息,请参见[存储定价详细信息](http://www.windowsazure.cn/zh-cn/pricing/details/storage/)。

单击“创建存储帐户”。

创建存储帐户可能需要一段时间。若要检查状态,您可以监视门户底部的通知。创建存储帐户后,您的新存储帐户将处于“联机”状态并且随时可供使用。

存储页面

热点内容
手机热点密码忘了怎么办 发布:2025-03-15 09:28:26 浏览:363
缓解压力锻炼方法 发布:2025-03-15 09:23:01 浏览:426
impdp存储过程 发布:2025-03-15 09:20:05 浏览:741
pythoniris 发布:2025-03-15 09:05:27 浏览:190
浪淘沙服务器怎么没有了 发布:2025-03-15 09:05:26 浏览:100
ftprpm安装包下载 发布:2025-03-15 09:03:53 浏览:723
如何判断背包配置 发布:2025-03-15 09:03:00 浏览:900
淘宝api源码 发布:2025-03-15 09:00:00 浏览:160
压缩复原修车 发布:2025-03-15 08:46:52 浏览:80
linux调试汇编 发布:2025-03-15 08:38:09 浏览:108