當前位置:首頁 » 存儲配置 » 創建存儲

創建存儲

發布時間: 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/)。

單擊「創建存儲帳戶」。

創建存儲帳戶可能需要一段時間。若要檢查狀態,您可以監視門戶底部的通知。創建存儲帳戶後,您的新存儲帳戶將處於「聯機」狀態並且隨時可供使用。

存儲頁面

熱點內容
手機上編寫c語言 發布:2025-03-15 08:17:53 瀏覽:752
上傳迅雷下載速度 發布:2025-03-15 08:07:50 瀏覽:552
好看解壓書 發布:2025-03-15 08:04:18 瀏覽:671
文字頁游源碼 發布:2025-03-15 08:02:29 瀏覽:315
怎麼看自己微信密碼 發布:2025-03-15 07:53:58 瀏覽:790
androidchecked 發布:2025-03-15 07:50:22 瀏覽:551
百度carplay怎麼連接安卓手機 發布:2025-03-15 07:49:39 瀏覽:24
捕捉圖片上傳 發布:2025-03-15 07:49:01 瀏覽:795
手機內核升級編譯 發布:2025-03-15 07:43:22 瀏覽:237
好java學校 發布:2025-03-15 07:43:22 瀏覽:136