|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
对于IT经理来说,令他们喜欢的MySQL的简单性还有另一方面。MySQL可以运行的更快速。某些人或许会说MySQL缺少了一些人们想要的功能。排序|优化|语句
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[OrderOptimize])andOBJECTPROPERTY(id,NIsProcedure)=1)
dropprocedure[dbo].[OrderOptimize]
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSOFF
GO
CREATEProcedureOrderOptimize
(
@IDint,
@intOrderint,
@TableNamevarchar(50)
)
AS
BEGINTRANSACTIONTransOrderOptimize
Declare@SqlStrnvarchar(500)
Declare@iint
Declare@CursorSqlnvarchar(500)
Declare@UpdateOrdernvarchar(500)
declare@TempIdint
--declare@CursorNamevarchar(50)
--print(Nupdate+cast(@TableNameasvarchar(50))+setintOrder=+cast(@intOrderasint)+whereID=+@ID+);
begin
set@SqlStr=Nupdate+cast(@TableNameasvarchar(50))+setintOrder=+cast(@intOrderasvarchar(50))+whereID=+cast(@IDasvarchar(10))+;
execsp_executesql@SqlStr;
end
Begin
setnocounton
set@i=0;
--set@CursorName=product;
--set@SqlTemp=NselectIDfrom+cast(@TableNameasvarchar(50))+ORDERBYintOrder;
--declareOrder_Cursorcursorforsp_executesql@SqlTemp
declare@tempnvarchar(500)
set@temp=NdeclareOrder_CursorcursorforselectIDfrom+cast(@TableNameasvarchar(50))+ORDERBYintOrder
execsp_executesql@temp
openOrder_Cursor
fetchnextfromOrder_Cursorinto@TempId
while@@FETCH_STATUS=0
Begin
--print@TempId;
set@i=@i+1;
set@UpdateOrder=NUpdate+cast(@TableNameasvarchar(50))+SetintOrder=+cast(@iasvarchar(10))+whereID=+cast(@TempIdasvarchar(10))+;
--print@UpdateOrder;
executesp_executesql@UpdateOrder
fetchnextfromOrder_Cursorinto@TempId
End
CLOSEOrder_Cursor
DEALLOCATEOrder_Cursor
End
if@@error0
Begin
raiserror(排序优化失利,请与开辟商接洽!,16,1)
RollBackTransactionTransOrderOptimize
Return99
end
CommitTransactionTransOrderOptimize
GO
SETQUOTED_IDENTIFIEROFF
GO
SETANSI_NULLSON
GO
应用程序需要使用数据库,数据库本身需要设计、开发和部署。还有MySQL学习教程,客户怎样实施混合系统,或者需要帮助管理多个云服务? |
|